3
I am developing a macro to perform filters using VBA, however in some columns, I have to uncheck some values, for example:
- Column
- Paul
- Fernanda
- Carla
- Láis
- 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 occurs an error, follows below the code:
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
You always access filterArray(0) and filterArray(1). If there are more filters ("Paula,Fernanda,Ricardo"), only two will be used. If there is only one, filterArray(1) will cause an error.
– RSinohara