Aretradeser
Board Regular
- Joined
- Jan 16, 2013
- Messages
- 176
- Office Version
- 2013
- Platform
- Windows
By kindness of the forum member GWteB, I was provided with the VBA code, that I put below, in which he included some lines of code to be able to choose, through a InputBox, a filter for Column 14.
This code allows me to choose a value of this column to filter, but when I need to filter by several of its values or all of them, it does not help me.
Could I add a line of code to this InputBox that allows me to do this, to choose several values to filter, even all?
This code allows me to choose a value of this column to filter, but when I need to filter by several of its values or all of them, it does not help me.
Could I add a line of code to this InputBox that allows me to do this, to choose several values to filter, even all?
Rich (BB code):
Sub InformeDesplazmientoEspaña()
On Error Resume Next
m = MsgBox("¿YOU WANT TO MAKE THE REPORT?", vbQuestion + vbYesNoCancel, "INFORME")
If m = vbCancel Then Exit Sub
Application.ScreenUpdating = False
Sheets("INFORMES").Unprotect ("123")
Sheets("BDATOS").Unprotect ("123")
Dim Crit As String
Crit = VBA.InputBox("Enter single criterion for column N", "AutoFilter")
Sheets("BDATOS").Range("A1").AutoFilter Field:=7, Criteria1:="Spain"
If Len(Crit) > 0 Then
On Error Resume Next
Sheets("BDATOS").Range("A1").AutoFilter Field:=14, Criteria1:=Crit
If Err.Number > 0 Then
MsgBox "Column N was not filtered" & vbNewLine & _
"(Error " & Err.Number & ": " & Err.Description & ")", vbExclamation, "Error on AutoFilter"
Err.Clear
End If
On Error GoTo 0
End If
With Sheets("INFORMES")
.Range("A2:L65536") = ""
Sheets("BDATOS").Range("A2:L" & Sheets("BDATOS").Range("a65536").End(xlUp).Row).SpecialCells(xlCellTypeVisible).Copy _
Destination:=.Range("A2")
.Cells.FormatConditions.Delete
.Range("A2:L" & .Range("a65536").End(xlUp).Row).Interior.ColorIndex = xlNone
End With
Sheets("BDATOS").AutoFilterMode = False
Sheets("BDATOS").Protect ("123")
'Application.ScreenUpdating = True
Sheets("INFORMES").Select
Ajustar
Range("A1").Select
Sheets("INFORMES").Protect ("123")
MsgBox "INFORME REALIZADO", vbInformation + vbOKOnly, "INFORME"
Exit Sub
End Sub