ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro continues to run (https://www.excelbanter.com/excel-programming/440335-macro-continues-run.html)

Rob

Macro continues to run
 
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.


Robert Crandal

Macro continues to run
 
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" wrote in message
...
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.



Bonnie[_6_]

Macro continues to run
 

"Rob" wrote in message
...
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


Bonnie[_6_]

Macro continues to run
 

"Robert Crandal" wrote in message
...
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


Rob

Macro continues to run
 
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.


"Robert Crandal" wrote:

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" wrote in message
...
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

Macro continues to run
 
Hi Bonnie,
Thanks for your help.

Regards,
Rob.

"Bonnie" wrote:


"Rob" wrote in message
...
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



All times are GMT +1. The time now is 04:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com