I have cells which will contain the below value
"Image not allowed|png"
I want to change the color of |png alone or whatever comes after "|"
Now i am trying to change the font color using the below code
Cells(4,2).Font.Color = RGB(255, 50, 25)
It will change the entire cells font color, Is it possible to change only the selected text color(|png
) using VBA?
Yes this is possible. A good way to explore the Excel object model is to use the macro recorder to record a macro where you manually carry out the manipulation you're interested in.
In this case, you can use:
Cell.Characters(Start:=1, Length:=5).Font
to set font properties of a substring in a cell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With