I need to use the value selected in list box(User form) to use as a array to apply on filter as a criteria. I am able to store the selected data in string but some how I can't use the data to apply filter.
Please check if there is any possibility to do this?
Please find the below code which I'm using.
Private Sub CommandButton1_Click()
Unload Me
MYVAR = ""
For x = 0 To ListBox1.ListCount - 1
If Me.ListBox1.Selected(x) Then
If MYVAR = "" Then
MYVAR = Me.ListBox1.List(x, 0)
MYVAR = """" & MYVAR & """"
Else
MYVAR = MYVAR & "," & Me.ListBox1.List(x, 0) & """"
End If
End If
Next x
ActiveSheet.Range("$A$1:$B$5").AutoFilter Field:=1, _
Criteria1:=Array(MYVAR), Operator:=xlFilterValues
'ActiveSheet.Range("$A$1:$B$5").AutoFilter Field:=1, Criteria1:=Array("T1", "T2"), Operator:=xlFilterValues
End Sub
Thank