推 jojofox90:謝謝S大 04/13 17:09
用暫存myRng(1 to 3)
再用application.union合併
Option Explicit
Option Base 1
Sub 多重篩選()
Dim myUsedRng As Range
Dim myRng(1 To 3) As Range, myRngAll As Range
Dim filterItem() As Variant
Dim i As Integer
Set myUsedRng = Range("A1").CurrentRegion
filterItem = Array("甲", "乙", "兩", "丁")
For i = 1 To 2
With myUsedRng
.AutoFilter
.AutoFilter field:=10, Criteria1:=filterItem((i - 1) * 2 + 1),
Operator:=xlOr, Criteria2:=filterItem((i - 1) * 2 + 2)
Set myRng(i) = .SpecialCells(xlCellTypeVisible)
End With
Next
Set myRngAll = Application.Union(myRng(1), myRng(2))
End Sub
※ 引述《jojofox90 (~CK~)》之銘言:
: 軟體:excel
: 版本:2003
: 不好意思
: 小弟有個問題想請問板上的高手
: 就是2007的篩選中可以進行多個篩選
: 但在2003的篩選中
: 只能進行二個條件的篩選
: 我想請問一下
: 板上是否有高手曾經寫過多個篩選的VBA程式碼嗎
: 可以提供讓小弟參考一下
: 謝謝~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.72.231.24