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.
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

MrGes

New Member
Joined
Aug 9, 2019
Messages
2
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,148
Office Version
  1. 365
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,010
Messages
5,599,330
Members
414,305
Latest member
scarletX

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
Top