VBA, Wildcard within an IF statement

Sarah12345

New Member
Joined
Jun 29, 2022
Messages
2
Platform
  1. Windows
Hi All,

I would like to add a wild card to help filter my results in case a user types in a word slightly differently, for example if a the data contains 'Van' or 'VAN' or 'Van 01' I would like to return all of those results.

Is there any way to add in a wildcard to help with this so I don't need to type out all of the variations?

Sheets("Raw_Data").Select
' Find the last row of data
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
' Loop through each row
For x = 1 To FinalRow
' Decide if to copy based on column A
ThisValue = Cells(x, 1).Value
If (ThisValue = "Van" Or ThisValue = "van" Or ThisValue = "Lorry" Or ThisValue = "lorry") Then
Cells(x, 1).Resize(1, 33).Copy
Sheets("Vehicle").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Sheets("Raw_Data").Select
End If
Next x
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
How about
VBA Code:
If LCase(ThisValue) Like "van*" Or LCase(ThisValue) Like "lorry" Then
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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