#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 251
Default Forcing to Uppercase

Quite some time ago I posted a question on this database regarding 'forcing
uppercase' and was given two macros, which I've used time and time again:
one to force the entire worksheet to uppercase and the other one was to
select just certain ranges to be uppercase, no matter how they were typed.
Neither one of the macros is quite right for what I need now. I need a macro
for just one cell.

Here's the macro I have to force the entire worksheet to uppercase:

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End Sub

This is the macro I have to force certain ranges to upper case:

Private Sub Worksheet_Change(ByVal Target As Range)
if target.cells.count 1 then exit sub
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is
Nothing) _
Then
With Target
If Not .HasFormula Then
application.enableevents = false
.Value = UCase(.Value)
application.enableevents = true
End If
End With
End If
End Sub

How do I modify either macro to be just one cell?

Connie
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Forcing to Uppercase

Maybe like this

If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End If
End Sub


Mike

"Connie Martin" wrote:

Quite some time ago I posted a question on this database regarding 'forcing
uppercase' and was given two macros, which I've used time and time again:
one to force the entire worksheet to uppercase and the other one was to
select just certain ranges to be uppercase, no matter how they were typed.
Neither one of the macros is quite right for what I need now. I need a macro
for just one cell.

Here's the macro I have to force the entire worksheet to uppercase:

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End Sub

This is the macro I have to force certain ranges to upper case:

Private Sub Worksheet_Change(ByVal Target As Range)
if target.cells.count 1 then exit sub
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is
Nothing) _
Then
With Target
If Not .HasFormula Then
application.enableevents = false
.Value = UCase(.Value)
application.enableevents = true
End If
End With
End If
End Sub

How do I modify either macro to be just one cell?

Connie

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 251
Default Forcing to Uppercase

Mike, that doesn't appear to work. I changed the $A$1 to the applicable cell
in my worksheet which is I23. However, I23 is I,J,K & L merged. But when
you click in the merged cells it says I23. So maybe this is creating a
problem with your macro. I then wondered if I use the macro for a range and
include the range of the merged cells if it would work and it does. So, I
tried yours in a blank worksheet, using A1 but it doesn't seem to work.
Connie

"Mike H" wrote:

Maybe like this

If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End If
End Sub


Mike

"Connie Martin" wrote:

Quite some time ago I posted a question on this database regarding 'forcing
uppercase' and was given two macros, which I've used time and time again:
one to force the entire worksheet to uppercase and the other one was to
select just certain ranges to be uppercase, no matter how they were typed.
Neither one of the macros is quite right for what I need now. I need a macro
for just one cell.

Here's the macro I have to force the entire worksheet to uppercase:

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End Sub

This is the macro I have to force certain ranges to upper case:

Private Sub Worksheet_Change(ByVal Target As Range)
if target.cells.count 1 then exit sub
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is
Nothing) _
Then
With Target
If Not .HasFormula Then
application.enableevents = false
.Value = UCase(.Value)
application.enableevents = true
End If
End With
End If
End Sub

How do I modify either macro to be just one cell?

Connie

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Forcing to Uppercase

Private Sub Worksheet_Change(ByVal Target As Range)
With Me.Range("A1")
If Not .HasFormula Then
On Error GoTo endit
Application.EnableEvents = False
.Value = UCase(.Value)
End If
End With
endit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP


On Thu, 7 Feb 2008 11:41:00 -0800, Connie Martin
wrote:

Quite some time ago I posted a question on this database regarding 'forcing
uppercase' and was given two macros, which I've used time and time again:
one to force the entire worksheet to uppercase and the other one was to
select just certain ranges to be uppercase, no matter how they were typed.
Neither one of the macros is quite right for what I need now. I need a macro
for just one cell.

Here's the macro I have to force the entire worksheet to uppercase:

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End Sub

This is the macro I have to force certain ranges to upper case:

Private Sub Worksheet_Change(ByVal Target As Range)
if target.cells.count 1 then exit sub
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is
Nothing) _
Then
With Target
If Not .HasFormula Then
application.enableevents = false
.Value = UCase(.Value)
application.enableevents = true
End If
End With
End If
End Sub

How do I modify either macro to be just one cell?

Connie


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Forcing to Uppercase

Connie,

Just a personal opinion but merging cells will sooner or later bite you on
the leg and I wouldn't ever do it but there you are, that's just me. The
macro does work even on merged cells if you address the top left cell of the
merged group. the reason it probably isn't now is that events are probably
disabled. run this sub and try again

Sub hh()
Application.EnableEvents = True
End Sub

"Connie Martin" wrote:

Mike, that doesn't appear to work. I changed the $A$1 to the applicable cell
in my worksheet which is I23. However, I23 is I,J,K & L merged. But when
you click in the merged cells it says I23. So maybe this is creating a
problem with your macro. I then wondered if I use the macro for a range and
include the range of the merged cells if it would work and it does. So, I
tried yours in a blank worksheet, using A1 but it doesn't seem to work.
Connie

"Mike H" wrote:

Maybe like this

If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End If
End Sub


Mike

"Connie Martin" wrote:

Quite some time ago I posted a question on this database regarding 'forcing
uppercase' and was given two macros, which I've used time and time again:
one to force the entire worksheet to uppercase and the other one was to
select just certain ranges to be uppercase, no matter how they were typed.
Neither one of the macros is quite right for what I need now. I need a macro
for just one cell.

Here's the macro I have to force the entire worksheet to uppercase:

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End Sub

This is the macro I have to force certain ranges to upper case:

Private Sub Worksheet_Change(ByVal Target As Range)
if target.cells.count 1 then exit sub
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is
Nothing) _
Then
With Target
If Not .HasFormula Then
application.enableevents = false
.Value = UCase(.Value)
application.enableevents = true
End If
End With
End If
End Sub

How do I modify either macro to be just one cell?

Connie

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forcing SaveAs to new name Rob Excel Discussion (Misc queries) 2 December 3rd 06 05:14 AM
Forcing an entry [email protected] Excel Discussion (Misc queries) 3 October 19th 06 10:04 PM
Forcing Text Kirk P. Excel Discussion (Misc queries) 2 September 26th 06 07:57 PM
forcing UDF to run Stefi Excel Worksheet Functions 4 December 29th 05 03:46 PM
Forcing a font throughout mattslav Excel Discussion (Misc queries) 3 June 8th 05 06:50 PM


All times are GMT +1. The time now is 08:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"