Richard,
Yet a cool solution from you. Thanks a lot.
I am trying to understand your code, but again, I am still climbing the learning curve.
Which part is actually identifying the Japanese characters?
I should appreciate if you could elaborate a little on your solution.
Again, thanks a lot.
Each unicode character takes up 2 bytes of data - the first byte identifies the character within the character set (assume standard Western character set, and CHAR(65) for example returns a capital A). The second byte identifies the character set: 0 is the Western set (also known as ANSI or extended ASCII set).
Hence, to identify non-Western characters, we just need to identify characters which are from a non-zero character set. Strings in VBA are stored in unicode, so when we assign a string value from a range to a string, we know that we end up with a unicode string:
strText = cell.Value
If we then assign the string to a byte array, we end up with the byte values of each string character within the byte array (2 bytes for each character, as explained above):
b = strText
Then we just need to loop thru the byte array and see if any of the character sets are non zero - since we know it is the second byte character that contains character se information, we only need to examine every second character which is what the For... Next does:
For i = (LBound(b) + 1) To UBound(b) Step 2
which loops from the 2 byte to the end incrementing by 2 each time (so we only look at the character set identifier).
If we find a non-zero one, then the cell contains something other than standard ANSI characters, so we highlight the cell in red. Then proceed to the next cell.
Make sense?
Jindon's code uses a regular expression and is somwhat wider ranging than mine (it will also highlight characters such as "@" or "~" or "#" in the cell values) - you may find it more suited to your needs, or not, if you don't have just alphanumerics in your file/path names.