View Single Post
  #6   Report Post  
Gord Dibben
 
Posts: n/a
Default

Daniel

One issue with your macro.

If any formulas in the range, they will be wiped out and changed to values
only.

Preferable to that would be David McRitchie's code.......

Sub optUpper_Click()
'David McRitchie, programming, 2003-03-07
Dim rng1 As Range, rng2 As Range, bigrange As Range
Dim Cell As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
On Error Resume Next
Set rng1 = Intersect(Selection, _
Selection.SpecialCells(xlCellTypeConstants))
Set rng2 = Intersect(Selection, _
Selection.SpecialCells(xlCellTypeFormulas))
On Error GoTo 0
If rng1 Is Nothing Then
Set bigrange = rng2
ElseIf rng2 Is Nothing Then
Set bigrange = rng1
Else
Set bigrange = Union(rng1, rng2)
End If
If bigrange Is Nothing Then
MsgBox "All cells in range are EMPTY"
GoTo done
End If
For Each Cell In bigrange
Cell.Formula = UCase(Cell.Formula)
Next Cell
done:
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


Gord Dibben Excel MVP

On Wed, 1 Jun 2005 12:36:05 -0500, "Daniel CHEN"
wrote:

Try the following code (assume you are familar with VBA/macro)

Sub muUpperCase()
Dim rngText As Range, cl As Range
Set rngText = Range("A1:B10")
For Each cl In rngText
cl = UCase(cl.Value)
Next
End Sub

You can change A1:B10 to any range you want.

===== * ===== * ===== * =====
Daniel CHEN

Spreadsheet/VBA Specialist

www.Geocities.com/UDQServices
Your "Impossible" Task Could Be Someone Else's "Piece of Cake"
===== * ===== * ===== * =====


"Joey" wrote in message
...
In MSWord, formatting can easily be set so that selected text is always in
capitals by FormatFontsAll Caps.

Can text in Excel be similarly formatted?