VBA change font colour of one character.

Akashwani

Well-known Member
Joined
Mar 14, 2009
Messages
2,911
Hi,

Is it possible for VBA to find all characters in red font on a worksheet and change those characters to a different font colour or bold or underscore?

Eg....
MrExcel = MrExcel
MrExcel = MrExcel
MrExcel = MrExcel


Thanks

Ak
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Hi. Example for single cell

Code:
Sub ToUscore()
Dim i As Long
With ActiveCell
    For i = 1 To Len(.Value)
        If .Characters(i, 1).Font.ColorIndex = 3 Then
            .Characters(i, 1).Font.ColorIndex = xlAutomatic
            .Characters(i, 1).Font.Underline = xlUnderlineStyleSingle
        End If
    Next i
End With
End Sub
 

Akashwani

Well-known Member
Joined
Mar 14, 2009
Messages
2,911
Hi Peter,

Thank you very much for your reply, it works great.
I don't want to be cheeky, but how would I get it to loop through every used cell and apply the formatting?

Thanks

Ak
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try this

Code:
Sub ToUscore()
Dim i As Long, c As Range
For Each c In ActiveSheet.UsedRange
    With c
        For i = 1 To Len(.Value)
            If .Characters(i, 1).Font.ColorIndex = 3 Then
                .Characters(i, 1).Font.ColorIndex = xlAutomatic
                .Characters(i, 1).Font.Underline = xlUnderlineStyleSingle
            End If
        Next i
    End With
Next c
End Sub
 

Akashwani

Well-known Member
Joined
Mar 14, 2009
Messages
2,911
:pray:

Thank you so very much Peter, I will be passing your code on and I'm sure it is going to make someone very happy.

Thanks Peter

Ak
 

Watch MrExcel Video

Forum statistics

Threads
1,122,521
Messages
5,596,653
Members
414,083
Latest member
Mrsash

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