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
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

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
 
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,167,651
Messages
5,854,958
Members
431,689
Latest member
jacker01

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