Excel Script

  • Thread starter Grayfox
  • 1 comments
  • 543 views
11,669
Australia
Australia
I_Grayson_Fox_I
I want to add a script in to an excel spreadsheet that will make any text in columns(E and F in my case) be uppercase.

I tried to use the scripts found online but they either make the whole document uppercase or dont work.

I will like to be make the changes automatically as well rather than requiring me to press Alt+F8 and selecting the macro to run.
 
The range isn't playing nice with my Excel (might be something to do with 64 bit version or the fact I stole it from a post from 2004?) but individual cells work alright with this:

Right click on the sheet name and select View Code. Paste this in then return to Excel.
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
   If Target = Range("E1") Then Target = UCase(Target.Value)
End Sub

Here is the ranged version that I can't get to work.
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
   [I]If Intersect(Target, Range("E1:E100")) Is Nothing Then Exit Sub[/I]
  
   Application.EnableEvents = False
   Target = UCase(Target)
   Application.EnableEvents = True
  
End Sub
 
Back