On 2002-02-25 13:02, NateO wrote:
Or you can force the issue without testing:
e.g.,
Sub Uppers()
Range("e1:e65536").Select
For Each cell In Selection
myrng = ActiveCell
ActiveCell = UCase(myrng)
ActiveCell.Offset(1, 0).Select
Next
End Sub
Cheers, Nate
One word of warning.
The above will convert any cells that contain formulas to values only.
To convert non-formula cells only to Upper :-
Sub Uppers()
Dim rng As Range, cell As Range
Set rng = Intersect(ActiveSheet.UsedRange, Columns(5))
For Each cell In rng
If cell.HasFormula = False Then
cell.Value = UCase(cell.Value)
End If
Next cell
End Sub
The following will convert cells to Upper and retain any formulas if the text being returned by the formula is contained as part of the formula(eg, ="a"), but will not convert to Upper if the result is obtained indirectly (eg, by a LOOKUP formula) :-
Sub Uppers()
Dim rng As Range, cell As Range
Set rng = Intersect(ActiveSheet.UsedRange, Columns(5))
For Each cell In rng
If cell.Formula <> "" Then
cell.Formula = Format(cell.Formula, ">")
End If
Next cell
End Sub