Changing Case

VENKYS

Board Regular
Joined
May 19, 2009
Messages
101
I need to convert text strings to proper case - ie first letter in each word in upper case, and all the remaining ones in lowercase. I can do the same with @Proper(A1) for single cell. Is there a way out to convert the whole range instead of converting one cell at a time.

Would a macro assist and how to go about.

Regards
 

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.
Try selecting the range then running

Code:
Sub ToProper()
Dim c As Range
For Each c In Selection
    c.Value = StrConv(c.Value, vbProperCase)
Next c
End Sub
 
Upvote 0
or perhaps you might be interested in this
Code:
Sub makeproper()
Selection.Value = Application.Proper(Selection)
End Sub
First select the range you want to make proper, or give it a name, or whatever.
 
Upvote 0
Try this, select the range you want to change and it gives you the three options of lower, upper and proper case.

Code:
Sub test()
Dim myCase, rng As Range, r As Range
myCase = Application.InputBox("Enter" & vbLf & "1 for Upper Case" & vbLf & _
                    "2 for Lower Case" & vbLf & "3 for Proper Case", type:=1)
If (myCase = False) + (Not myCase Like "[1-3]") Then Exit Sub
On Error Resume Next
Set rng = Selection.SpecialCells(2)
On Error GoTo 0
If Not rng Is Nothing Then
    For Each r In rng
        r.Value = StrConv(r.Value, myCase)
    Next
End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

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