How does you code integrate into your project, spread sheet? Could a For...Next loop be used?Code
Though I must admit I haven't seen too much of this used:
If the color is not exactly Excel.XlRgbColor.rgbYellow it might just return a false in the IF statement.
I would generally use a more standard approach:
I think you might run into some problems here because some country codes have the same beginnings but different lengths, like The Dominican Republic's country codes are +1809, +1829, and +1849 - this could lead to a confusion with the US. Even worse there are countries that share one country code, e.g. USA & Canada both use +1, while Russia & Kazakhstan use +7
If you have a finite amount of countries that could work. you could use vlookup in a (slightly) tedious nested formula.Code
This formula assumes the telephone number to be in cell A1, the Formula could be in B1. The CountryCodes Sheet has the numbers in colum A and country names in Column B.
It basically tries to match the leftmost 4 characters, then 3, then 2, then 1, but it will ignore 5 digit country codes, because I'm not sure how much overlap CountryCode & Local Code can have.
Though I kinda would think of making a UDF if you understand VBA, could make the formula easier.
Edit: I want mention that I found that formula on another board after a google search. just modified it slightly to explain it easier.