I have a table with 15 columns (A:O).In 12th column (L) which contain 200 countries. I want to remove (Making invisible) more than 1 countries from that filter using InputBox. I used the code below and it is not working. It is showing error "Type mismatch".
If i am not using <> , then it is selecting only user entered data. But i want to deselect the user entered data. How to use "not equal to" inside an Array. Help me
Sub Removecountries()
Dim str1 As Variant
Dim Data As Variant
str1 = Application.InputBox("Enter the Country - comma separated ")
Sheet2.ListObjects("DataTable").Range.AutoFilter Field:=12
If InStr(1, str1, ",") > 0 Then
Data = Split(str1, ",")
For i = LBound(Data) To UBound(Data)
Sheet2.ListObjects("DataTable").Range.AutoFilter Field:=12, Criteria1:=Array("<>" & Data), Operator:=xlFilterValues 'error
Next i
Else
Sheet2.ListObjects("DataTable").Range.AutoFilter Field:=12, Criteria1:=("<>" & str1), Operator:=xlFilterValues
End If
End Sub