VBA: Macro to UPPERCASE selected cells that have bolded objects/words

SimonTheWicked

New Member
Joined
Aug 22, 2019
Messages
3
Hi guys,

This is my first post in MrExcel.com

I've been looking for a solution in Excel 2016 to uppercase selected cells (which is easy) but I only need words which are bolded to uppercase, not all of them.

Any ideas on how I can make such a macro? Help would be greatly appreciated.

Regards,
Simon
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This works with the activecell. Changing to work with a range of cells is easy.

Code:
Sub UpperCaseBold()
    Dim i As Integer
    For i = 1 To Len(ActiveCell.Value)
        If ActiveCell.Characters(i, 1).Font.Bold Then
            ActiveCell.Characters(i, 1).Text = UCase(ActiveCell.Characters(i, 1).Text)
        End If
    Next
End Sub

This could take a long time to run on a large group of cells since it is working character by character.
 
Upvote 0
This works with the activecell. Changing to work with a range of cells is easy.

Code:
Sub UpperCaseBold()
    Dim i As Integer
    For i = 1 To Len(ActiveCell.Value)
        If ActiveCell.Characters(i, 1).Font.Bold Then
            ActiveCell.Characters(i, 1).Text = UCase(ActiveCell.Characters(i, 1).Text)
        End If
    Next
End Sub

This could take a long time to run on a large group of cells since it is working character by character.

Works like a charm! Only works with one cell at a time, but I think that will be enough. I can hotkey the macro.
 
Upvote 0
Works like a charm! Only works with one cell at a time, but I think that will be enough. I can hotkey the macro.

I modified shknbk2 code to make it work in selection, try this:

Code:
Sub UpperCaseBold()
    Dim c As Range, i As Long
    Application.ScreenUpdating = False
    For Each c In Selection
        For i = 1 To Len(c)
            If c.Characters(i, 1).Font.Bold Then
                c.Characters(i, 1).Text = UCase(c.Characters(i, 1).Text)
            End If
        Next
    Next
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
[SOLVED] VBA: Macro to UPPERCASE selected cells that have bolded objects/words

I modified shknbk2 code to make it work in selection, try this:

Code:
Sub UpperCaseBold()
    Dim c As Range, i As Long
    Application.ScreenUpdating = False
    For Each c In Selection
        For i = 1 To Len(c)
            If c.Characters(i, 1).Font.Bold Then
                c.Characters(i, 1).Text = UCase(c.Characters(i, 1).Text)
            End If
        Next
    Next
    Application.ScreenUpdating = True
End Sub

Woah, even better. Thank you, Akuini :)

Thank you guys, this is EXACTLY what I've been looking for.
 
Upvote 0
Re: [SOLVED] VBA: Macro to UPPERCASE selected cells that have bolded objects/words

You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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