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
you can try
If InStr(stateString, "Alabama") > 0 Then MainPage.Shapes(11).Copy
or
If StrComp(stateString, "Alabama" , 1)=0 Then Mainpage.Shapes(11).Copy
Note: not tested
Thanks, but I specifically need it to compare the abbreviation. I have the code already written to compare the full state name. I just can't get it to work when it is comparing the abbreviation.