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 can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
: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
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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
Back
Top