Combining 2 Worksheet_change codes

MikeWip

New Member
Joined
Feb 13, 2017
Messages
45
hello guys, I have a Worksheet_change code that is working perfectly well (see below). I would like to add another code, using the same functionality i.e. (Worksheet_change) so that all entries in column HA are automatically Uppercase.
How can I add a second code, right after the one below so all entries in column HA are systematically in Upper case?

Thanks guys in advance for your help with that. I am a beginner and I am still learning :)
cheers!!!
Mike

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo CleanExit:

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

Application.EnableEvents = False

If Target.Value = "PROMO" Then
Target.Offset(0, 202).Value = "Y"
Else
Target.Offset(0, 202).Value = ""
End If

Application.EnableEvents = True

End If

Exit Sub

CleanExit:
Application.EnableEvents = True
Err.Clear


End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Are you saying you also input data manually into column HA because this change event inserts data into column HA doesnt it?
 
Upvote 0
Code:
Me.[HA:HA] = [INDEX(UPPER(HA:HA),)]

Add this line before the Exit Sub line, or before the last End If line if you only want it to execute if you change something in Col G. Let me know if this worked for you.
 
Last edited:
Upvote 0
that is correct, we can also insert data manually onto column HA... unless the first code gets activated and put the Y in that column HA.

thanks for your help.
Mike
 
Upvote 0
sorry mate, this code doesn't work.
thanks for the quick reply. I do appreciate it :)

Please clarify what happens, tested and working on my end.

I must add that it's for the better to determine the last row in the HA column, that would significantly reduce the line's processing time.
 
Last edited:
Upvote 0
I think the issue is coming from 'merged cells'.

Can we say, Range("HA7:HA1000") always be uppercase instead of column HA...
my sheet keeps running and running... can't stop.

cheers for your help,

Mike
 
Upvote 0
Code:
[COLOR=#333333]Me.[HA7:HA1000] = [INDEX(UPPER(HA7:HA1000),)][/COLOR]


EDIT

I now notice you do not enable events before making changes in the worksheet. Basically, you made a self-activating macro. The sub activates when something in the sheet is changed, which causes changes to be made, which causes the sub to fire again, which causes changes to be made.... You get the picture

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents= False

Application.EnableEvent= True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

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