Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Why change color or bold in part of one cell is not working anymore?

Writer Andrew Mclaughlin

In Excel, it was posible change the font color in part of a cell.

I've tried the below code. It's not working in updated Excel 365 for value (not formula),

Set ce=cells(5,3)
ce.Characters(1, 5).Font.Color = vbBlue

It should change the color in 5 first characters in the cell, but it changes the color of all cell content. Even interactively it's not working. One select a piece inside a cell, press a color. When exits the cell, it colours all the cell content (in the same way of VBA code)

Why?

Update: It's my fault. One just can colour part of a text not a number. With text, both VBA or not works OK

18

1 Answer

After the discussion in comments, Excel accept partial color cell to text content, but not for number content.

So put ABCDEFG in a active cell. The below code colour the 5 first characters in red. Interactivally it also works.

ActiveCell.Characters(1, 5).Font.Color = vbRed

Now put 1234567 in a active cell. The below code paint all in red. Interactivally the color remains the same before.

ActiveCell.NumberFormat = "@" // Even if you format as text doesn't work
ActiveCell.Characters(1, 5).Font.Color = vbRed

The same code works if you just put a B before 1234567 ...

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.