Sub MakeUpper()
Dim MySht As Worksheet, MyCell As Range
For Each MySht In ThisWorkbook.Sheets
For Each MyCell In MySht.UsedRange.Cells
MyCell = UCase(MyCell)
Next
Next
End Sub
There is no such example for this on Chip's page, but you
probably want to change the
MyCell = UCase(MyCell)
to
MyCell.formula = UCase(MyCell.formula)
so you don't wipe out formulas.
My own solution would be "Back to Kindergarten" in http://www.mvps.org/dmcritchie/excel/proper.htm#upper
which should be considerably, and ignores formulas and
empty cells. Your use of UsedRange will eliminate the
vast ocean of empty cells, but not those within the used range.
Sub Upper_All_Sheets()
'David McRitchie
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim x As String, ws As Object, Cell As Range
x = MsgBox("Use CANCEL to abort changing all constant " _
& "cells to uppercase", vbOKCancel)
If x = vbCancel Then Exit Sub
For Each ws In ActiveWorkbook.Sheets
On Error Resume Next 'In case no cells in selection
ws.Activate
For Each Cell In Cells.SpecialCells(xlConstants, xlTextValues)
Cell.Value = UCase(Cell.Value)
Next
Next ws
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
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.