Worksheet event / Add new cell event change to call new macro

cidfidou

Board Regular
Joined
Jan 19, 2009
Messages
163
Hi Excel Jedis,

I am using the below event change for 3 cells ("C2,F2,G6") and calling SortTableChartWB.

how can i trick the below code to add another cell change (O6) to call "Macro2".

As usual, thanks in advance


Private Sub Worksheet_Change(ByVal Target As Range)
Dim Changed As Range, c As Range, myRange As Range



Application.ScreenUpdating = False
Application.EnableEvents = False

Set myRange = Range("C2,F2,G6")


Set Changed = Intersect(Target, myRange)

If Not Changed Is Nothing Then

For Each c In Changed
Call SortTableChartWB
Next c

End If


Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi,

I have re-written your original code so this might not be what you want.

However, I could not see why you needed to run SortTableChartWB three times if all three cells were changed.
So if it is not right please come back and I will fix it.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim Changed As Range, c As Range, myRange As Range

    Application.ScreenUpdating = False
    Application.EnableEvents = False
    
    If Not Intersect(Target, Range("O6")) Is Nothing Then Call macro2
    If Not Intersect(Target, Range("C2,F2,G6")) Is Nothing Then Call SortTableChartWB
    
    Application.EnableEvents = True
    Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,106
Messages
6,128,863
Members
449,473
Latest member
soumyahalder4

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