Macro to run when cell is changed

levy77

Board Regular
Joined
May 7, 2019
Messages
67
I have set up some code so that when cells G3:I3 change a macro runs using the below code.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address = "$G$3" Or Target.Address = "$H$3" Or Target.Address = "$I$3" Then
        Call ScheduleModule.UpdateSchedule
    End If
    
End Sub

That will then run another sub, UpdateSchedule. When the update schedule macro runs, it changes cells and other things. The issue I have is that when anything on the sheet changes, it goes back to the above code and runs it again. It will always return false as the 'UpdateSchedule' macro never changes the cells G3:I3 but its does slow the program down significantly.

Any ideas of ways around this? Cheers.
 

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
Hi, try this
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("G3:I3")) Is Nothing Then
        Application.EnableEvents = False
        Call ScheduleModule.UpdateSchedule
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Target, Range("G3:I3")) Is Nothing Then
        Application.EnableEvents = False
        Call ScheduleModule.UpdateSchedule
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

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