VBA AutoFilter HELP!

Xyleene

New Member
Joined
Mar 7, 2018
Messages
5
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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top