I need a macro that will copy the corresponding shape outline of a state when that state's abbreviation is in "stateString". The following code works when searching for "Al" for Alabama, but it will also return true when "stateString" contains "Alaska" or any city with an "Al" in it.
How do you make InStr look for exact match whole words only?
If InStr(stateString, "Al") > 0 Then MainPage.Shapes(11).Copy
I think, first you need to break the variable stateString into two words - the name of the city and the name of the state. And then if the second word consists of only two letters, then consider it an abbreviation and look for the name of the state
ok, thanks. I'll have to check into this. I also just realized that adding a space in front of the abbreviation will solve the problem I'm having the majority of the time:
If InStr(stateString, " Al") > 0 Then MainPage.Shapes(11).Copy