Help with formating in VBA

Certified

Board Regular
Joined
Jan 24, 2012
Messages
189
Hi,

How would write a vba code to format the following line?

Text in red text in blue text in red
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

humdingaling

Board Regular
Joined
Sep 26, 2007
Messages
136
Something along the lines of

Code:
    With Range("A1")
        .Characters(Start:=1, Length:=12).Font.Color = vbRed
        .Characters(Start:=13, Length:=12).Font.Color = vbBlue
        .Characters(Start:=25, Length:=12).Font.Color = vbRed
    End With

anymore, you're to need to be more specific in your needs

the syntax would be something along the lines of
Code:
Activecell.Characters(Start:=k, Length:=j).Font.Color = vbred
whereby K = start and j = length of what you want colored
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,026
Messages
5,835,022
Members
430,332
Latest member
Charly_Moon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top