Why don't numeric cells have the .Characters () property?

With any text value, I can individually format each character, and then copy this formatting to another cell, iterating over Range.Characters() Collection.

However, if the cell is a number (even if the Formatting number displays it as a string, for example, dates), then it does not open the .Characters() property and, indeed, cannot be selectively formatted by numbers.

Why does Excel display strings using character objects but not numbers, even when a number is displayed as a string?

+5
source share
1 answer

If you want to get around this, you can do the following:

In cell A1, put '123456 with a' '' in front. Then write

 range("A1").Characters(1,3).Font.Bold = true 

Only the first three numbers are required, not taking into account the "" sign. So the number looks like a string, but you can still use its calculations, for example. A1 + 4 will give 123460.

+1
source

Source: https://habr.com/ru/post/1246455/


All Articles