Macro continues to run

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

Hi,
The following code works well with the exception that when the Message Box
appears and the cursor is moved off the Message Box on to the worksheet the
hour glass appears instead of the mouse pointer. I presume this means that
the macro is still running.

Sub CheckVolumeRise1()
If Range("g6") < Range("h6") < Range("k6") Then
MsgBox Range("a6") & " has reached criteria"
End If
End Sub

Please will someone advise me on what to do.

Thank you.
 
I ran this code and I didn't see any hourglass at all. I'm not sure
why the hour glass is appearing in your case.

BTW, is it okay in VBA to use the less than operator like
that ('If Range("g6") < Range("h6") < Range("k6") Then')??
I thought you had to use the AND operator between those,
such ast he following:

If (Range("g6") < Range ("h6")) AND (Range("h6") < Range("k6")) then
' Do stuff here
End If

Also, you you trying to compare a range or are you trying to compare
the values inside those cell ranges??? If you are comparing cell contents,
shouldn't you use: Range("g6").value ' etc, etc... ????

Robert
 
Rob said:
Hi,
The following code works well with the exception that when the Message Box
appears and the cursor is moved off the Message Box on to the worksheet
the
hour glass appears instead of the mouse pointer. I presume this means that
the macro is still running.

Sub CheckVolumeRise1()
If Range("g6") < Range("h6") < Range("k6") Then
MsgBox Range("a6") & " has reached criteria"
End If
End Sub

Please will someone advise me on what to do.

Thank you.

Rob,

You are correct. Until you click a button in the message box, in your case
the 'OK' button, the macro is still running. You see the hourglass because
it is awaiting a reply to the message box. Once you click a button in the
message box, the code resumes at the line immediately following the MsgBox
line.

An option to avoid having to click a button in the message box is to create
a userform or a textbox and make it visible for a few seconds and then hide
it. This way your code can continue uninterrupted without requiring user
input of any kind.

HTH,

Bonnie
 
Robert Crandal said:
I ran this code and I didn't see any hourglass at all. I'm not sure
why the hour glass is appearing in your case.

BTW, is it okay in VBA to use the less than operator like
that ('If Range("g6") < Range("h6") < Range("k6") Then')??
I thought you had to use the AND operator between those,
such ast he following:

If (Range("g6") < Range ("h6")) AND (Range("h6") < Range("k6")) then
' Do stuff here
End If

Also, you you trying to compare a range or are you trying to compare
the values inside those cell ranges??? If you are comparing cell
contents,
shouldn't you use: Range("g6").value ' etc, etc... ????

Robert,

Although, it is good practice to specify *exactly* what is being compared, I
believe .Value is the default property of a range object. To compare
something other than the range value, that property (eg:
Range("G6").Address) would have to be explicitly coded.

I hope others will weigh in if I am incorrect.

Bonnie
 
Hi Robert,
Thanks for your help. I am a brand newbie at this VBA programming. So in
answer
to your questions. I really would not know.

Regards,
Rob.
 
Hi Bonnie,
Thanks for your help.

Regards,
Rob.

Bonnie said:
Rob,

You are correct. Until you click a button in the message box, in your case
the 'OK' button, the macro is still running. You see the hourglass because
it is awaiting a reply to the message box. Once you click a button in the
message box, the code resumes at the line immediately following the MsgBox
line.

An option to avoid having to click a button in the message box is to create
a userform or a textbox and make it visible for a few seconds and then hide
it. This way your code can continue uninterrupted without requiring user
input of any kind.

HTH,

Bonnie
 
Back
Top