Setting macro priorities & Ontime command

jey_sea

New Member
Joined
Apr 23, 2010
Messages
24
Is there a way to set priorities to macros; that is, can I set a priority on one macro to force it to finish before a command button will trigger another macro?

to further complicate things, I'm using the OnTime command to cause a program to loop itself until a flag gets set by a command button; see below:
Note: the MakeEnaMeasurement routine takes mS to complete!
-------------------------------------------------------------
Sub MakeEnaMeasurement()
Set WB = Application.ActiveWorkbook
Set WSRD = WB.Sheets("RawData")
If WSRD.Cells(1, 3) = False Then GoTo SingleMeasurement
Application.OnTime Now + TimeValue("00:00:01"), "MakeEnaMeasurement"
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
SingleMeasurement:
Code
Goes
Here
<o:p> </o:p>End Sub
--------------------------------------------------------
CommandButton_Click()

if WSRD.Cells(1, 3) = true then
WSRD.Cells(1, 3)= false (to my helper see comment below)
ContMeas = true
end if

More Code
Goes
Here
if ContMeas = true then
ContMeas=false
WSRD.Cells(1, 3) = true
call MakeEnaMeasurement
end if

End Sub

------------------------------------------------------

Comment: now when the command button is hit; I want the code to make the single measurement (thus stop the 1-second loop) and then perform all the commands in the command button routine, if you notice I will then get the loop going again at the conclusion of the command button routine.

Is there a better way to do something like this?

The code works but sometimes it appears the code is jumping out of the middle of the measurment routine take care of the command button code?

Any help with setting priorities would help me.

Thanks




my problem is, I want to make sure the code is executed to the end
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,224,507
Messages
6,179,172
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top