Column to Proper Case

marka87uk

Board Regular
Joined
Mar 24, 2007
Messages
247
I have some text which is in capitals filling a column. How can I loop though each cell of text and change it to proper case (or simply just change the whole column)? :)
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You can use =PROPER(A1) then Copy-->Paste Special-->Values or try:

Code:
Sub TextCon()
'code by Ivan F. Moala
    Dim oCell As Range, Ans As String
    
    Ans = Application.InputBox("Type in Letter" & vbCr & _
        "(L)owercase, (U)ppercase, (S)entence, (T)itles ")
    If Ans = "" Then Exit Sub
    
    For Each oCell In Selection.SpecialCells(xlCellTypeConstants, 2)
        Select Case UCase(Ans)
            Case "L": oCell = LCase(oCell.Text)
            Case "U": oCell = UCase(oCell.Text)
            Case "S": oCell = UCase(Left(oCell.Text, 1)) & _
                LCase(Right(oCell.Text, Len(oCell.Text) - 1))
            Case "T": oCell = Application.WorksheetFunction.Proper(oCell.Text)
        End Select
    Next

End Sub

HTH,

Smitty
 
Upvote 0
Thanks, that pointed me in the right direction. In the end I did this:

Code:
Range("F1").Select
Range(Selection, Selection.End(xlDown)).Select
Dim pCell As Range
For Each pCell In Selection
pCell.Value = Application.WorksheetFunction.Proper(pCell.Value)
Next pCell

Not sure if there is a simpler way but that works fine for me! :)
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,479
Members
448,967
Latest member
visheshkotha

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