Home |
Search |
Today's Posts |
#1
|
|||
|
|||
EXCEL
HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY
|
#2
|
|||
|
|||
Just because you want upper case in that cell, you don't have to inflict it
on us. Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Target.Address = "$H$1" Then With Target .Value = UCase(.Value) End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob Phillips "John Davies" <John wrote in message ... HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY |
#3
|
|||
|
|||
Thanks Bob Phillips
This works fine on 1 cell, however there are another 3 individual cells that should show only uppercase. I have tried pasting the code again with different cell values but I get a compile error. Is there a way to do this? "John Davies" wrote: HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY |
#4
|
|||
|
|||
Change
If Target.Address = "$H$1" Then to the cells you want, for example If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then -- HTH Bob Phillips "John Data" wrote in message ... Thanks Bob Phillips This works fine on 1 cell, however there are another 3 individual cells that should show only uppercase. I have tried pasting the code again with different cell values but I get a compile error. Is there a way to do this? "John Davies" wrote: HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY |
#5
|
|||
|
|||
Bob
I changed the line as you advised but nothing happens after I paste the code. The pasted lines are as follows:- Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then With Target .Value = UCase(.Value) End With End If ws_exit: Application.EnableEvents = True End Sub Is ther anything wrong with these? Thanks "Bob Phillips" wrote: Change If Target.Address = "$H$1" Then to the cells you want, for example If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then -- HTH Bob Phillips "John Data" wrote in message ... Thanks Bob Phillips This works fine on 1 cell, however there are another 3 individual cells that should show only uppercase. I have tried pasting the code again with different cell values but I get a compile error. Is there a way to do this? "John Davies" wrote: HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY |
#6
|
|||
|
|||
John,
It works fine for me. Make sure you have events enabled, type this in the VB IDE immediate window Application.EnableEvents = True and return. -- HTH Bob Phillips "John Data" wrote in message ... Bob I changed the line as you advised but nothing happens after I paste the code. The pasted lines are as follows:- Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then With Target .Value = UCase(.Value) End With End If ws_exit: Application.EnableEvents = True End Sub Is ther anything wrong with these? Thanks "Bob Phillips" wrote: Change If Target.Address = "$H$1" Then to the cells you want, for example If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then -- HTH Bob Phillips "John Data" wrote in message ... Thanks Bob Phillips This works fine on 1 cell, however there are another 3 individual cells that should show only uppercase. I have tried pasting the code again with different cell values but I get a compile error. Is there a way to do this? "John Davies" wrote: HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY |
#7
|
|||
|
|||
Thanks Bob
I restarted Excel and the code now works fine but I did not understand what you meant by "have events enabled, type this in the VB IDE immediate window". Where is that?" "Bob Phillips" wrote: John, It works fine for me. Make sure you have events enabled, type this in the VB IDE immediate window Application.EnableEvents = True and return. -- HTH Bob Phillips "John Data" wrote in message ... Bob I changed the line as you advised but nothing happens after I paste the code. The pasted lines are as follows:- Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then With Target .Value = UCase(.Value) End With End If ws_exit: Application.EnableEvents = True End Sub Is ther anything wrong with these? Thanks "Bob Phillips" wrote: Change If Target.Address = "$H$1" Then to the cells you want, for example If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then -- HTH Bob Phillips "John Data" wrote in message ... Thanks Bob Phillips This works fine on 1 cell, however there are another 3 individual cells that should show only uppercase. I have tried pasting the code again with different cell values but I get a compile error. Is there a way to do this? "John Davies" wrote: HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY |
#8
|
|||
|
|||
Hi John,
The code I gave you is worksheet event code. There is a property called EnableEvents which can be turned on or off. If Off, the event will not fire, so nothing happens. If you look at the code you will see Application.EnableEvents = False at the start, and Application.EnableEvents = True at the end. This is done to stop events cascading from our code. The immediate window is a window in the VB IDE (Alt-F11). You open it from the ViewImmediate Window (or Ctrl-G). This allows you test things out in immediate mode, or look at variables when stepping through code. -- HTH Bob Phillips "John Data" wrote in message ... Thanks Bob I restarted Excel and the code now works fine but I did not understand what you meant by "have events enabled, type this in the VB IDE immediate window". Where is that?" "Bob Phillips" wrote: John, It works fine for me. Make sure you have events enabled, type this in the VB IDE immediate window Application.EnableEvents = True and return. -- HTH Bob Phillips "John Data" wrote in message ... Bob I changed the line as you advised but nothing happens after I paste the code. The pasted lines are as follows:- Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then With Target .Value = UCase(.Value) End With End If ws_exit: Application.EnableEvents = True End Sub Is ther anything wrong with these? Thanks "Bob Phillips" wrote: Change If Target.Address = "$H$1" Then to the cells you want, for example If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then -- HTH Bob Phillips "John Data" wrote in message ... Thanks Bob Phillips This works fine on 1 cell, however there are another 3 individual cells that should show only uppercase. I have tried pasting the code again with different cell values but I get a compile error. Is there a way to do this? "John Davies" wrote: HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY |
#9
|
|||
|
|||
Hi Bob
Thanks for all your help "Bob Phillips" wrote: Hi John, The code I gave you is worksheet event code. There is a property called EnableEvents which can be turned on or off. If Off, the event will not fire, so nothing happens. If you look at the code you will see Application.EnableEvents = False at the start, and Application.EnableEvents = True at the end. This is done to stop events cascading from our code. The immediate window is a window in the VB IDE (Alt-F11). You open it from the ViewImmediate Window (or Ctrl-G). This allows you test things out in immediate mode, or look at variables when stepping through code. -- HTH Bob Phillips "John Data" wrote in message ... Thanks Bob I restarted Excel and the code now works fine but I did not understand what you meant by "have events enabled, type this in the VB IDE immediate window". Where is that?" "Bob Phillips" wrote: John, It works fine for me. Make sure you have events enabled, type this in the VB IDE immediate window Application.EnableEvents = True and return. -- HTH Bob Phillips "John Data" wrote in message ... Bob I changed the line as you advised but nothing happens after I paste the code. The pasted lines are as follows:- Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then With Target .Value = UCase(.Value) End With End If ws_exit: Application.EnableEvents = True End Sub Is ther anything wrong with these? Thanks "Bob Phillips" wrote: Change If Target.Address = "$H$1" Then to the cells you want, for example If Not Intersect(Target, Range("H1,M5,O11,F7")) Is Nothing Then -- HTH Bob Phillips "John Data" wrote in message ... Thanks Bob Phillips This works fine on 1 cell, however there are another 3 individual cells that should show only uppercase. I have tried pasting the code again with different cell values but I get a compile error. Is there a way to do this? "John Davies" wrote: HOW CAN I MAKE A SINGLE CELL IN EXCEL DISPLAY UPPERCASE ONLY |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"Group" function very slow with Excel 2003 :( ... While very quick with Excel2000 :O) | Excel Discussion (Misc queries) | |||
Stop Excel Rounding Dates | Excel Discussion (Misc queries) | |||
Hints And Tips For New Posters In The Excel Newsgroups | Excel Worksheet Functions | |||
Excel error - Startup (and Acrobat PDFMaker) | Setting up and Configuration of Excel | |||
Excel 2002 and 2000 co-install. Control Which Starts ? | Excel Discussion (Misc queries) |