Change Font Case

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello All, Can I have some help please on this.

This neat piece of code allows you to select a range of cells and then run this macro to change the font to
Upper Case, Lower Case, or Proper Case.
To do this you have to remove the comment tag for each case you want. Is it possible that when you run the macro a message box pops up and lets you to select which case font you want.


Sub ChangeCase()
Dim Rng As Range
On Error Resume Next
Err.Clear
Application.EnableEvents = False
For Each Rng In Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues).Cells
If Err.Number = 0 Then
' Rng.Value = StrConv(Rng.Text, vbUpperCase)
'Rng.Value = StrConv(Rng.Text, vbLowerCase)
Rng.Value = StrConv(Rng.Text, vbProperCase)
End If
Next Rng
Application.EnableEvents = True
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
My choice would be:

Code:
Sub ChangeCase()
    Dim Rng As Range, iModus As Integer
    Do Until iModus <= 3
        iModus = Application.InputBox("Please choose 1 for UPPERCASE, 2 for lowercase, 3 for ProperCase", "Case selection", 0, Type:=1)
    Loop
    Application.EnableEvents = False
    On Error Resume Next
    For Each Rng In Selection.SpecialCells(2, 2).Cells
        Rng.Value = StrConv(Rng.Text, iModus)
    Next
    Application.EnableEvents = True
End Sub


EDIT: a nice code for post number 5,000 :)
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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