How to concatenate two subs Worksheet_change

Worf99

New Member
Joined
Jan 13, 2018
Messages
44
Hi everyone,


I have a file in which I inserted a sub Worksheet_change that automatically transforms the user input (in this case only the names and surnames of members) in capital letters.


Code:
Private Sub Worksheet_Change(ByVal Target As Range)


''''''''''''''''''''''''''''''''''''''''''''


'Forces text to UPPER case for the range A1:B20


''''''''''''''''''''''''''''''''''''''''''''


If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub






    On Error Resume Next


    If Not Intersect(Target, Range("A1:B20")) Is Nothing Then


      
        Application.EnableEvents = False


        Target = UCase(Target)


        Application.EnableEvents = True


    End If


    On Error GoTo 0






End Sub




I have another file in which it is transformed into "day MONTH year", ex. "6 OCTOBER 2018", the date entered by the user.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Range("D1")) Is Nothing Then
    If Target <> "" Then
        Target = UCase(Format(Target, "D MMMM YYYY"))
    End If
End If
Application.EnableEvents = True
End Sub





I can not get the two subs to live on the same sheet, because I would like to capitalize both the names and the date.


I attach sample files.






Thanks for the tips!


Matt
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Combine them into one with a structure along these lines.

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("A1:B20")) Is Nothing Then
    'Rest of first code here
  End If

  If Not Intersect(Target, Range("D1")) Is Nothing Then
    'Rest of second code here
  End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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