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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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