it might be easier just to actually run the macro called Disable.
but
in VBE, in the project list, dbl-click THISWORKBOOK
in the left combo box above the code, select workbook
in the right combo box above the code, select SHEETCHANGE
If Sh.Range("A1").Value = "stop" Then Disable
(note: DISABLE macro MUST be in the same module with the worksheet code above)
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Intersect(Target, Range("$A$1")) = "Stop" Then
Call Disable
End If
Application.EnableEvents = True
End Sub
I've tried both suggestions but neither work. I have code in Module1 that automatically refreshes the workbook every x secs and I use two command buttons that start and stop the refresh.
The command buttons work fine. Sub Disable stops the refresh when i press the command button assigned to a macro called Disable. What I am trying to do now is get the refresh to stop if "Stop" appears in A1 OR I press the command button. I thought that linking to the macro would do it but it doesn't.
Hope that makes sense. Any ideas to get this working?
Attached is a workbook where I was able to get your requirements, as understood, met. Currently "Stop" is in A1 but it will not work until it is typed in or F2/Enter, because it is a change event.
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.