G
Guest
Excel Helper
I have a problem that I have never encountered before and could use some help.
In simple terms I want to run a procedure that calls another procedure
within that code. The procedure allows a worksheet to be added to a workbook,
with the user specifying a name via InputBox. However, before the worksheet
is added the procedure checks the 'value' of a given cell (cell S3). If that
= "ON" then some of the figures on the existing worksheet are changed
(divided by 10) and a menu item on a custom menu is updated (has a tick mark
next to it using msoButtonDown).
My code looks something like this:
Public Sub InsertSheet()
Dim answer As String
If Worksheets(Worksheets.Count - 2).Range("S3") = "ON" Then
Call ToggleRunRate
End If
answer = InputBox("Enter worksheet name", "Add Sheet")
....more code here...
End sub
The problem that I am having is as follows.
If cell S3 is not equal to 'ON' then the code works fine and I get a prompt
for the InputBox and all subsequent code does what it ought to.
If cell S3 equals 'OFF' then the procedure 'ToggleRunRate' executes as it
should but the InputBox does not appear. It is as if the procedure cannot
progress any further than Call ToggleRunRate, even though no error is
generated.
Some things that I would add that may help:
(1) I have checked the state of Application.ScreenUpdating to see if that is
preventing execution but all seems fine.
(2) The procedure ToggleRunRate is in a separate module. I have defined it
as Public. I don't see why this would make a difference?
I have never had this issue before. All I can think of is that because of
the operation that ToggleRunRate performs i.e. makes some calculations on a
worksheet and amends the appearance of a menu item, that this is in some way
interfering with the code?
I wonder if anybody has any suggestiins on this? I can give more details if
needed.
Regards
Alex Park
I have a problem that I have never encountered before and could use some help.
In simple terms I want to run a procedure that calls another procedure
within that code. The procedure allows a worksheet to be added to a workbook,
with the user specifying a name via InputBox. However, before the worksheet
is added the procedure checks the 'value' of a given cell (cell S3). If that
= "ON" then some of the figures on the existing worksheet are changed
(divided by 10) and a menu item on a custom menu is updated (has a tick mark
next to it using msoButtonDown).
My code looks something like this:
Public Sub InsertSheet()
Dim answer As String
If Worksheets(Worksheets.Count - 2).Range("S3") = "ON" Then
Call ToggleRunRate
End If
answer = InputBox("Enter worksheet name", "Add Sheet")
....more code here...
End sub
The problem that I am having is as follows.
If cell S3 is not equal to 'ON' then the code works fine and I get a prompt
for the InputBox and all subsequent code does what it ought to.
If cell S3 equals 'OFF' then the procedure 'ToggleRunRate' executes as it
should but the InputBox does not appear. It is as if the procedure cannot
progress any further than Call ToggleRunRate, even though no error is
generated.
Some things that I would add that may help:
(1) I have checked the state of Application.ScreenUpdating to see if that is
preventing execution but all seems fine.
(2) The procedure ToggleRunRate is in a separate module. I have defined it
as Public. I don't see why this would make a difference?
I have never had this issue before. All I can think of is that because of
the operation that ToggleRunRate performs i.e. makes some calculations on a
worksheet and amends the appearance of a menu item, that this is in some way
interfering with the code?
I wonder if anybody has any suggestiins on this? I can give more details if
needed.
Regards
Alex Park