yesAre or could these bold words be mixed in with non-bold words all within the same cell?
To better explain. I created a database with food labeling information and I made all allergens bold. Now I want to change this to make ale the allergens in Capital letters/ Upper case. So I would like the macro to:Are or could these bold words be mixed in with non-bold words all within the same cell?
Sub MakeBoldUpper()
Dim rng As Range
Dim cl As Range
Dim ch As Object
Dim idx As Long
Set rng = Range("A1:A10")
For Each cl In rng.Cells
For idx = 1 To cl.Characters.Count
If cl.Characters(idx, 1).Font.Bold Then
cl.Characters(idx, 1).Text = UCase(cl.Characters(idx, 1).Text)
cl.Characters(idx, 1).Font.Bold = False
End If
Next idx
Next cl
End Sub
It did not work I got the following error:Try this, adjust the range as needed.
VBA Code:Sub MakeBoldUpper() Dim rng As Range Dim cl As Range Dim ch As Object Dim idx As Long Set rng = Range("A1:A10") For Each cl In rng.Cells For idx = 1 To cl.Characters.Count If cl.Characters(idx, 1).Font.Bold Then cl.Characters(idx, 1).Text = UCase(cl.Characters(idx, 1).Text) cl.Characters(idx, 1).Font.Bold = False End If Next idx Next cl End Sub
I changed the range to ("C2:J2") just to test ik on the first row of the database. The range actually should be ("C2:J3500").Did you change anything?