Reputation: 1332
With any text value, I can individually format each character and then copy that formatting to another cell by iterating over the Range.Characters()
Collection.
However, if the cell is a number (even if the numberFormatting displays it as a string e.g. dates) then it does not expose a .Characters()
property and, indeed, cannot be selectively formatted digit-by-digit.
Why does Excel display strings using Character objects but not numbers, even when the number is being displayed as a string?
Upvotes: 5
Views: 207
Reputation: 43593
If you want to go around this, you may do the following:
In cell A1 put '123456 with the " ' " sign in front. Then write
range("A1").Characters(1,3).Font.Bold = true
It would take only the first three numbers, not taking into account the " ' " sign. Thus, the number is kind of displayed as a string, but you can still use it calculations e.g. A1 + 4 would give 123460.
Upvotes: 1