Help with formating in VBA

Certified

Board Regular
Joined
Jan 24, 2012
Messages
179
Hi,

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

Text in red text in blue text in red
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

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:

Watch MrExcel Video

Forum statistics

Threads
1,122,820
Messages
5,598,297
Members
414,224
Latest member
Crazy_FC

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