I’m using excel’s vba to match some numerical ratings. The rating can include a suffix:
- + add .25 to the rating
- – subtract .25 from the rating
- “ add .50 to the rating
So for example if the rating: 5″ would really mean 5.5 or 5+ would mean 5.25
I have a simple conditional:
if ActiveCell.Characters(i,1).Text Like [123456789+-"] then ...
Unfortunately the ” produces an invalid character error. I’ve tried escaping as follows:
but can’t seem to get the code to work. Thus, my question: How do you match a single double quote using excel VBA’s Like function.
Use double quotes around
Basically, when using
Like, the regex is wrapped in double quotes and the double quote inside it is escaped with a second one.
Note that the
- (hyphen) needs to be at the start or end of the regex, otherwise it denotes a range of characters. Thanks @ssarabando !