I am developing a macro to perform filters using VBA, however in some columns, I have to uncheck some values, for example:
- Column
- Paulo
- Fernanda
- Carla
- Lais
- Renata
I want everything that is different from Paulo, Fernanda and Renata. How can I do this?
I created a macro that works with two values, if I put one only an error occurs, the code below follows:
c = 1
Do While c <= coluna
If MyRange = Cells(1, c) Then
filtrocomp = InputBox("Qual o operador de comparação?" & vbCrLf & "Ex: <,<=,=,>,>=,<>", "Comparação_MAF")
filtro = InputBox("Qual o filtro de " & MyRange & " Deseja aplicar?", "Comparação_MAF")
If filtrocomp <> "" Or filtro <> "" Then
filtrosArray() = Split(filtro, ",")
Val (filtrosArray(0))
Cells(1, c).Select
Selection.AutoFilter Field:=c, Criteria1:=filtrocomp & filtrosArray(0), Operator:=xlAnd, _
Criteria2:=filtrocomp & filtrosArray(1)
Exit Do
Else
MsgBox "Nenhum filtro foi realizado!!", vbInformation, "Comparação_MAF"
End If
End If
c = c + 1
Loop