Wildcards or values in a macro?

Closed
sworcester Posts 3 Registration date Tuesday November 22, 2016 Status Member Last seen November 22, 2016 - Nov 22, 2016 at 11:58 AM
 Blocked Profile - Nov 22, 2016 at 04:58 PM
Hello, I created a macro (by recording) that looks at the names and picks them based on the full name.
Is there a way to just use a wildcard?
Instead of the list being "Superman", "Super man", "Supergirl", "Super girl"
could I use something like "Super*", assuming I wanted all values with "super" in the beginning of the text value.

I have tried that example and it doesn't work.

2 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Nov 22, 2016 at 12:06 PM
Hi Sworcester,

Use "Like" instead of "=" when using "*" as in:
If range("A1").value like "*Super*" then

or
If left(range("A1").value,5) = "Super" then
will work as well.

Best regards,
Trowa
0
sworcester Posts 3 Registration date Tuesday November 22, 2016 Status Member Last seen November 22, 2016
Nov 22, 2016 at 03:39 PM
Here is kinda what gets spit out

Sub SMC_Sys()
'
' SMC_Sys Macro
'

'
ActiveSheet.Range("$A$1:$CH$52073").AutoFilter Field:=14, Criteria1:=Array( _
"Vendor 1", "vendor 2", "another", "yet another", _
etc etc etc... ), Operator:= _
xlFilterValues
End Sub

I am trying to not have to alter much or write much, instead using the RECORD function to d most of the work. The idea is to create a macro that is portable for every month so the RANGE may change each month as well
0
Blocked Profile
Nov 22, 2016 at 04:58 PM
So load the range into a variable, and load that variable as the range. NOT EVERYTHING COMES WITH AN EASY BUTTON!
0