I'm trying to get a grasp on when I can and cannot use * to generalize while coding.
An example of what I mean is xfile.* if the extension does not matter.
Another would be *.xls if I want to refer to any and all excel files.
I'm not just interested in files though. I want to use something like Washington* and Oregon* if I want all sheets in a workbook regardless of what comes after, be it This Month, This Year, etc.
Another level would be values in cells on a spreadsheet.
I ask for each of these specifically because * seems to be treated differently in each scenario.
Thanks for the help.
EDIT:
A good example of an issue I just ran into is in this code:
If ActiveSheet.Name <> "City*" Then
code
End If
The options for worksheet names are City MTD, City YTD, Country MTD, and Country YTD (Month to Date and Year to Date, fyi)
The sheet i'm on is City MTD but my program still enters the If-Statement. This leads me to believe that * is not being treated as a wildcard, but rather as a literal asterisk in the string.
Here is how you would use
*to access all sheets whose names fit a certain pattern:When I run this on a workbook that has 1 sheet named "Raw Data" and another "Processed Data" (and some other sheets that don't contain "data" anywhere in them) I get:
*is useful for many purposes, but is somewhat limited. For more complicated problems it is advisable to use VBScript's regular expression object -- which can be also be used in VBA (if you add the right reference to the project).