I am trying to count the number of times a specific cell value occurs within an Excel spreadsheet, using VBA. The cell value is an XML tag, and the angle brackets are interpreted by the function as less than/more than. How can these characters be escaped?
Microsoft says:
"You can use the wildcard characters, question mark (?) and asterisk (*), for the criteria. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character."
But this does not seem to work for me. My code:
count = WorksheetFunction.CountIf(Sheets("Sheet1").Range("A:A"), "<element>")
This should push the bracket to be read as part of the string since the equals sign is read as the evaluation.
count = WorksheetFunction.CountIf(Sheets("Sheet1").Range("A:A"), "=<element>")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With