返回列表 上一主題 發帖

[發問] Re : 請教 : 進階篩選但不要篩選隱藏的資料

本帖最後由 GBKEE 於 2010-6-16 14:29 編輯
PD961A, 檔案沒錯, 之前已請板主幫忙download 了. 謝謝 : )
但zz5151353 大並沒有解說怎麼將隱藏的資料不會 ...
ji5kimo 發表於 2010-5-11 11:53


用進階篩選是不行的
Sheet1,Sheet2, Sheet3 中Group欄請取消合併的儲存格
  1. Sub Ex()
  2.     Dim Sh As Worksheet, W As Worksheet, R As Range, Rng As Range
  3.     For Each Sh In Sheets(Array("Sam", "Jeff", "Joe"))
  4.         Sh.Range("A5:H" & Rows.Count).Clear
  5.         For Each W In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
  6.             Set Rng = Nothing
  7.             For Each R In W.Range("A1").CurrentRegion.Rows
  8.                 If Not R.Hidden And R.Cells(4) Like Sh.[d2] Then
  9.                     If Rng Is Nothing Then
  10.                         Set Rng = R
  11.                     Else
  12.                         Set Rng = Union(Rng, R)
  13.                     End If
  14.                 End If
  15.             Next
  16.             If Not Rng Is Nothing Then
  17.                 Rng.Copy Sh.Range("b" & Rows.Count).End(xlUp)(2, 0)
  18.             End If
  19.         Next
  20.     Next
  21. End Sub
複製代碼

TOP

本帖最後由 GBKEE 於 2010-6-16 21:48 編輯

回復 5# Hsieh


   
Set A = Columns("D")

Hsieh板主 你少點一點
Set A = .Columns("D")
  1. Sub Ex()
  2.     Dim Sh As Worksheet, W As Worksheet, R As Range, Ar()
  3.     For Each Sh In Sheets(Array("Sam", "Jeff", "Joe"))
  4.         Sh.Range("A5:H" & Rows.Count).Clear
  5.         ReDim Preserve Ar(0)
  6.         For Each W In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
  7.             For Each R In W.Range("A1").CurrentRegion.SpecialCells(xlCellTypeVisible).Cells.Rows
  8.                 If R.Cells(4) Like Sh.[d2] Then
  9.                     Ar(UBound(Ar)) = R.Value
  10.                     ReDim Preserve Ar(UBound(Ar) + 1)
  11.                 End If
  12.             Next
  13.         Next
  14.         ReDim Preserve Ar(UBound(Ar) - 1)
  15.         If UBound(Ar) > 0 Then
  16.             Sh.Range("b" & Rows.Count).End(xlUp)(2, 0).Resize(UBound(Ar) + 1, 8) = Application.Transpose(Application.Transpose(Ar))
  17.         End If
  18.     Next
  19. End Sub
複製代碼

TOP

1. Ar(UBound(Ar)) = R.Value // Ar(s) = .Cells(B.Row, 1).Resize(, 8).Value


回復 8# ji5kimo
1. Ar(UBound(Ar)) = R.Value // Ar(s) = .Cells(B.Row, 1).Resize(, 8).Value
這行可以將背景顏色也copy 進去嗎 ?

Ar是陣列(Array) 無法將背景顏色也copy
2. A 欄group 的資料有辦法一起進來嗎 ? 這樣似乎就沒法用array了 ?

不是不行  A 欄儲存格你用合併來顯示對資料的捉取 增加了複雜性

TOP

        靜思自在 : 有願放在心裡,沒有身體力行,正如耕田不播種,皆是空過因緣。
返回列表 上一主題