S Oberlander
Board Regular
- Joined
- Nov 25, 2020
- Messages
- 147
- Office Version
- 365
- Platform
- Windows
The below code depends on another macro to have run first, so I put in some code to check if that macro ran and if not to call it.
It is also designed to be able to get called multiple times, and to skip some steps if it is being run the second time.
My code works when I step thru it. It also works if the first macro
What am I doing wrong? I told the code what it is supposed to do in case of an error.
Note, the way I check if the given macro ran already is by checking for a sheet that gets added and named within that macro
It is also designed to be able to get called multiple times, and to skip some steps if it is being run the second time.
My code works when I step thru it. It also works if the first macro
NonqualRates
ran already, but if NonqualRates
did not run yet it gets stuck by If Sheets("Exceptions").Visible = False Then
; giving me Run-time error '9": subscript out of range.What am I doing wrong? I told the code what it is supposed to do in case of an error.
Note, the way I check if the given macro ran already is by checking for a sheet that gets added and named within that macro
VBA Code:
Sub IqmPossibile()
On Error GoTo firstep
If Sheets("Pivot").Visible = True Then GoTo secondstep
firstep: 'runs NonqualRatesl
Call NonqualRates
secondstep: 'checks if this is first run for IqmPossible
On Error GoTo thirdstep
If Sheets("Exceptions").Visible = False Then GoTo fourthstep 'this is where it gets stuck; the "False" here is not a mistake, it is checking for a hidden sheet.
thirdstep: 'does this only if it is the first run
On Error GoTo 0
'long winded stuff happen here, not relevant to my question
fourthstep: 'continue to userform
IQMPossibilities.show vbModeless
End Sub