Have you declared any global variables? If so they may have values when the macro first runs.
Have you disabled events
Have you set manual calculation
Do you use "on error" to handle your errors?
'This code will ignore any errors
So use this to select sheet1 for example
Check to see if the active sheet name is Sheet1
If not create Sheet1
But you must undo the error option as soon as possible
This Tells excel where to go if there is an error
On error goto ErrorSkip
Sheets("Sheet1").activate
Goto Skip
ErrorSkip:
'If you are here the Sheet1 does not exist so create it
Skip:
' Ok at this point Sheet1 must exist
'So enable default error handling
On Error Goto 0
You could set a Global Variable
Dim ChangeFlag as Boolean
then check if the flag is set before running a macro
this will mean you control which macros are run
Public ChangeFlag as Boolean
sub Macro1()
If ChangeFlag = True then exit sub
ChangeFlag = True
'Run Macro2
Macro2
ChangeFlag = false
End sub
Sub Macro2()
If ChangeFlag = True then exit sub
'This will never run
End sub
Bookmarks