0
我想選擇一個年份和業務類型(1或更多),然後自動篩選一列。這樣,我只能使用1個宏而不是爲所有替代品製作多個宏。選擇多個列表框項目來設置過濾器
(Year Select)
(Type of Business)
這是我的時刻:
Private Sub Botton1_Click()
Public Platform As String
Public Year as Integer
Platform = UserForm1.LB2.Text
Year = UserForm1.LB1.value
Unload UserForm1
End Sub
......
Private Sub UserForm_Initialize()
With LB1
.AddItem "2016"
.AddItem "2017"
.AddItem "2018"
End With
With LB2
.AddItem "CMP"
.AddItem "AS"
.AddItem "MasterBread"
.AddItem "CMI -Andino"
.AddItem "CMI -Brasil"
.AddItem "CMI -CAMEC"
.AddItem "CMI -ConoSur"
.AddItem "Global"
End With
End Sub
年將永遠是隻值1但商業類型可以是1或更多。
如何存儲多個列表框的值以便將該變量作爲過濾器調用?
這是我需要調用變量:
ActiveSheet.Range("$A$1:$G$1500").AutoFilter Field:=4, Criteria1:="2016"
ActiveSheet.Range("$A$1:$G$1500").AutoFilter Field:=2, Criteria1:="=AS", _
Operator:=xlOr, Criteria2:="=MASTER BREAD"
在這個例子中,我需要過濾「2016」和「AS & MASTER麪包」。
[這](http://mariaevert.dk/vba/?p=140)將幫助。 –