how can i make a cell always show text in caps

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

Guest

I want to set up certain columns in my spreasheet so that all text entered
into it shows in caps
 
If you have a formula, use the UPPER() function. Assuming your cell is
user-entered, you'd need an event macro. For example. put this in your
worksheet code module (right-click on the worksheet tab and choose View
Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Range("A1")
If Not Intersect(Target, .Cells) Is Nothing Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End Sub
 
Two quibbles -

This code assumes that there's only one cell selected. If Range("Input")
was defined as cell J1, and cells A1:J10 were selected, cell A1 would
be coerced to upper case, not J1.

Also, without disabling events, assigning the value will create a
recursive call to Worksheet_Change, which will terminate when XL runs
out of stack space. Fortunately, XL terminates nicely, in that case, but
it's not good practice.
 

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