All Caps Code Help

motherteresa

Board Regular
Joined
Nov 11, 2010
Messages
81
I have this All Caps code which works great. But, it also turns all emails on the worksheet into caps, which I don't want.

Question:
Is there a way to have it work on everything except emails and web addresses?

or

Is there a way to have it work on everything except certain cells?


Thank you Ex(cel)perts!!;)
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Maybe you should post the code you have, and then provide the criteria you need to turn off all caps.
 
Upvote 0
Oh...duh. Blonde moment. I had it copied and then forgot to paste:oops:

Here it is:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
With Application
.EnableEvents = False
Target = UCase(Target)
.EnableEvents = True
End With
End Sub
 
Upvote 0
You might be able to do something like this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
    With Application
        .EnableEvents = False
            If InStr(Target.Value, "@") Then
            Else: Target = UCase(Target)
            End If
            .EnableEvents = True
    End With
End Sub

HTH,
 
Upvote 0
Oh well...it got complicated. Thanks in advance for any further help.

In some of the sheets it works. In other sheets it doesn't, because I already have another worksheet macro in place it seems to be in conflict with.

So, is there a way to just apply it to the whole workbook, or is there a way to incorporate it into a worksheet that has the conflicting macro?

Here's the other macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range, MyRange As Range
If Intersect(Target, Range("C:C, E:E")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
Select Case Target.Column
Case 5
If Target > 0 Then Target = -Target
Case 3
If Target < 0 Then Target = -Target
End Select
Application.EnableEvents = True
End Sub
 
Upvote 0
Not sure what the Dim's are for as the variables aren't use in the code you supplied, but this should do what you want. I don't usually use Exit Sub, so I changed the If...Then's around a bit.


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cel As Range, MyRange As Range
    
    If Target.Cells.Count = 1 Then
        On Error Resume Next
        Application.EnableEvents = False
        If InStr(Target.Value, "@") = 0 Then
            Target = UCase(Target)
        End If
    
        If Not Intersect(Target, Range("C:C, E:E")) Is Nothing Then
            Select Case Target.Column
                Case 5
                    If Target > 0 Then Target = -Target
                Case 3
                    If Target < 0 Then Target = -Target
            End Select
        End If
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0
(y)
Up late happy dancing over here. Y'all are so helpful!! Thanks Smitty and djreiswig. That looks like it's a winner.
 
Upvote 0
:(Help Smitty and djreiswig (or anyone)!! That combo code seems to be wiping out formulas embedded in the cells.

For instance, when I change the value of any cell or edit it's formula, any formula is wiped out and all that is left is the value.

When I take the macro out, it stops doing that. Can you offer any assistance?:cry:
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top