EXCEL VBA篩選問題?

2016-08-20 6:34 am
已知[B:F]都是數字,[A]是編號
B1到F1是做為篩選的數字內容
B1是11,篩選到的內容的最右邊內容是
105104 10 13 22 29 30
105175 2 4 10 18 30
105185 11 22 25 32 36
105188 1 2 3 11 34
但我想要的只有最下面兩列,想在AA1:AF1跟AA2:AF2顯示這兩列
105185 11 22 25 32 36
105188 1 2 3 11 34
同樣的C1=13篩選到的在AA3:AF3跟AA4:AF4顯示最下面這兩列
105108 2 11 29 34 38
105110 4 20 24 25 35
D1=18篩選到的在AA5:AF5跟AA6:AF6顯示這兩列
105159 9 28 32 36 37
105196 2 4 20 28 32
E1和F1也是一樣
更新1:

檔案參考下載地址 http://www.FunP.Net/520355

更新2:

參考檔案下載網址 https://www.sendspace.com/file/frcptz

更新3:

CHENG大: 檔案已經重新上傳 可不可以麻煩再幫我看一下 您目前的答案不是我要的

更新4:

補充,B1只對[B:B],C1只對[C:C]做篩選

回答 (2)

2016-09-19 11:27 am
Sub TT()

Dim xT, c, x, i
[Z:AF].ClearContents

Set xT = CreateObject("Scripting.Dictionary")
For Each x In [B1:F1]
Set c = x.EntireColumn.Find(x)
If Not c Is Nothing Then
i = 0
firstAddress = c.Address
Do
If c.Row > 1 And Cells(c.Row, 19) <> "" Then
i = i + 1
xT(i) = Cells(c.Row, 19).Resize(, 6)
End If
Set c = Columns(x.Column).FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If

Set c = Range("Z" & x.Column * 2 - 3)
c.Value = x
c(1, 2).Resize(, 6) = xT(i + (i > 1))
c(2, 2).Resize(, 6) = xT(-i * (i > 1))
Next x

End Sub
2016-08-20 1:19 pm
檔案無法下載
不太懂篩選條件如果是篩選儲存相同就複製
大概.....
Sub test()
k = 1
For Each c In Range("B2:F22")
If c = Range("B1") Then
Range("B" & c.Row & ":F" & c.Row).Copy Range("AA" & k)
k = k + 1
End If
Next
End Sub


收錄日期: 2021-05-03 13:46:53
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20160819223416AAxMGwZ

檢視 Wayback Machine 備份