How do I change certain cells to Uppercase

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a Worksheet in Excel 2000, but would like to format certain
cells so that they show in Uppercase text. Can anyone help with this?

Thanks
 
this might be useful. Suggest putting in personal.xls.

Sub ChangeCase()
Application.ScreenUpdating = False
Dim r As Range
nCase = UCase(InputBox("Enter U for UPPER" & Chr$(13) & " L for
lower" & Chr$(13) & " Or " & Chr$(13) & " P for Proper", "Select
Case Desired"))
Select Case nCase
Case "L"
For Each r In Selection.Cells
If r.HasFormula Then
r.Formula = LCase(r.Formula)
'R.Formula = R.Value
Else
r.Value = LCase(r.Value)
End If
Next

Case "U"
For Each r In Selection.Cells
If r.HasFormula Then
r.Formula = UCase(r.Formula)
'R.Formula = R.Value
Else
r.Value = UCase(r.Value)
End If
Next
Case "P"

For Each r In Selection.Cells
If r.HasFormula Then
r.Formula = Application.Proper(r.Formula)
'R.Formula = R.Value
Else
r.Value = StrConv(r.Value, vbProperCase)
End If
Next
End Select
Application.ScreenUpdating = True
End Sub
 
TazDevil said:
I have created a Worksheet in Excel 2000, but would like to format certain
cells so that they show in Uppercase text. Can anyone help with this?

No way to do this by formatting. Only using macros. If you want to do this
to appear all-caps immediately after entry, use a Change event handler.
First, select the cells that should be all-caps, and give that range the
defined name AllCapsRange. Then right-click on the worksheet tab and select
View Code from the pop-up menu. Enter the following Change event handler.


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, _
Me.Names("AllCapsRange").RefersToRange) Is Nothing Then Exit Sub

On Error GoTo ExitProc
Application.EnableEvents = False

If Not Target.HasFormula And VarType(Target.Value) = vbString Then
Target.Value = IIf(Left(Target.Value, 1) Like "[=+]", "'", "") & _
UCase(Target.Value)
End If

ExitProc:
Application.EnableEvents = True
End Sub
 

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

Back
Top