The sheet code to format a column to upper case


Posted by Joe Was on May 15, 2001 12:17 PM

Does anyone know the sheet code to set a column, so any text upper or lower is reset to upper only on input?

Posted by Kevin James on May 15, 2001 1:19 PM

User your browser to search for the word "upper" on the main message page. It is the 2nd listing after your question.

Posted by Joe Was on May 15, 2001 1:27 PM

The code below came from the main message page, see code

This code formats the whole page not just column "E" any ideas on how to fix it?

Private Sub Worksheet_Change(ByVal Target As Range)
'Change col5 to upper case only
Dim rCell As Range
Dim LookRange As Range

Set LookRange = Range("E7", Range("E1000").End(xlUp))
For Each rCell In LookRange
On Error Resume Next
Application.EnableEvents = False
Target = UCase(Target)
Next rCell
Application.EnableEvents = True

End Sub


Posted by Joe Was on May 15, 2001 1:54 PM

This code worked it changes a specific column to upper case on enter.

This code finally worked. It changes lower case text to upper case, for one specific column on a sheet, when "Enter" is pressed or the focus moves to a new cell.

Private Sub Worksheet_Change(ByVal Target As Range)
'Change col5 to upper case only
Dim rCell As Range
Dim LookRange As Range

Application.EnableEvents = False
Set LookRange = Range("E7", Range("E1000").End(xlUp))
For Each rCells In Selection
Application.EnableEvents = False
LookRange = UCase(LookRange.Text)
Next
Application.EnableEvents = True

End Sub




Posted by Joe Was on May 17, 2001 5:32 AM

Re: This code worked better it came from Bertie.

If you use code in the sheet tab module it must be named the name below. If you put it on a control or on the macro pages you can name it anything you want.

The solution came from Bertie and works like a charm. In my actual application I changed the columns in the code above. So it should work with any column range. Thank's Bertie, JSW.