Find bolded words in cell and change to upper case letters

jassie22

New Member
Joined
Jan 31, 2021
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
Good day,

I have a database with a lot of bold words (not all of them), I now need these words to change to upper case letters and unbold them. Is there a way to do this with a VBA?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Are or could these bold words be mixed in with non-bold words all within the same cell?
 
Upvote 0
Are 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:

* Find the words in bold
* Change to upper case
* Unbold the word
* loop Through the database and do this for all the bold words.

Thank you in advance!!!
 
Upvote 0
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
 
Upvote 0
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
It did not work :( I got the following error:

Error 1004 during execution: Property Text of Class Characters cannot be set.
 
Upvote 0
Just so you know, Norie's code worked fine for me using range C2:J3500.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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