Hi
I'm a complete newbie when it comes to VBA script. I have a file that i want to include some Autofilter data search fields in but am having some trouble with trying to figure out how to make the following script do this:
1. Point script to search in cell A2 but search as a wildcard. Meaning a user can type in partial words - like App instead of Apple
2. If noting listed in A2 search in B2 instead as a wildcard. If the user doesn't want to fill in cell A2 - search on B2 instead with the same type wildcard search - like bann instead of Banana
Something like an If/Then?
Option Explicit
Sub AutoFilterData()
Dim wsData As Worksheet
Set wsData = ThisWorkbook.Worksheets("Flat-All")
With wsData
On Error Resume Next
'//Reset AutoFilter
.ShowAllData
.Range("A9:AG9").AutoFilter 5, .Range("A2")
.Range("A9:AG9").AutoFilter 4, .Range("B2")
End With
'//Close my objects
Set wsData = Nothing
End Sub
I'm a complete newbie when it comes to VBA script. I have a file that i want to include some Autofilter data search fields in but am having some trouble with trying to figure out how to make the following script do this:
1. Point script to search in cell A2 but search as a wildcard. Meaning a user can type in partial words - like App instead of Apple
2. If noting listed in A2 search in B2 instead as a wildcard. If the user doesn't want to fill in cell A2 - search on B2 instead with the same type wildcard search - like bann instead of Banana
Something like an If/Then?
Option Explicit
Sub AutoFilterData()
Dim wsData As Worksheet
Set wsData = ThisWorkbook.Worksheets("Flat-All")
With wsData
On Error Resume Next
'//Reset AutoFilter
.ShowAllData
.Range("A9:AG9").AutoFilter 5, .Range("A2")
.Range("A9:AG9").AutoFilter 4, .Range("B2")
End With
'//Close my objects
Set wsData = Nothing
End Sub