changing case

J

Jeff

Lets say column A has the data below:

Row1: john SMITH
Row2: Jane DOE
Row3: tom brown
Row4: john doe
Row5: TOM smith

What I need is VBA code to select the range above and
change all letters to uppper-case. Thanks
 
B

Bob Phillips

Jeff,

Dim cell As Range

For Each cell In Range("A1:A5")
cell.Value = UCase(cell.Value)
Next cell

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
S

Shailesh Shah

Hi Jeff,

Try this,

This will Change Text as under

Lower case to UPPERCASE
UPPERCASE to Title Case
Title Case to lowercase

Sub SelectCase()
'Assign Shortcut key
Dim C As Range, rng As Range, cc As Integer
If Selection.Count = 1 Then
Set rng = Selection.SpecialCells(xlCellTypeConstants).Cells
Else
Set rng = Selection
End If
Set C = rng(1)
Select Case True
Case C = LCase(C)
cc = 1
Case C = UCase(C)
cc = 2
Case Else
cc = 3
End Select
Application.EnableCancelKey = xlErrorHandler
On Error GoTo xit
Application.EnableEvents = 0
For Each C In rng
With C
.Formula = Choose(cc, UCase(.Formula),
Application.Proper(.Formula), LCase(.Formula))
End With
Next C
xit:
Application.EnableEvents = 1
End Sub


For a free add-ins download from below site.

Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top