trigger a macro

lburch

New Member
Joined
Nov 6, 2011
Messages
15
hi i have a cell that is formatted as a time, it is in cell G4, and i have recorded a macro (called macro1) that takes all the values from one sheet and puts them in another sheet. Is there a way to have the macro triggered automatically when the timer in cell G4 gets below 10:00 min. If so what is the step by step process to do it as i haven't written code before.
Thankyou
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi

Will try to give you as much info as I can. I am assuming you are using Excel 2007.

1. Ensure Developer TAB is on the Ribbon, if Not. Do the following.
2. Click The Office Button in the top left hand corner.
3. Click Excel Options Bottom Right
4. Tick "Show Developer TAB on Ribbon
5. Click OK

Once Developer TAB is evident select it. Then do the following.

1. Copy The Code below to the clipboard.
2. Select Visual basic on the left of the ribbon.
3. Select Sheet from left hand pane "prob. Sheet1(Sheet1)"
4. From Left hand drop down in the right hand pane select "Work Sheet"
5. From Right hand Drop down in right pane select change
6. Insert The code you copied earlier here where the cursor is positioned.

Code:
Application.ScreenUpdating = False
Static counter
On Error Resume Next
If Range("g4").Value < 0.416666667 And counter < 1 Then 'Action Criteria
 
Call Macro1  'Your Macro Name
 
 
End If
counter = 1 ' Counter Increased to 1 to stop the macro being called each time the Sheet changes when the timer is less than 10 Mins
 
If Range("g4").Value >= 0.416666667 Then counter = 0    ' Set Counter to 0  if Time Greater Than 10 mins

Back to your sheeet now, when the counter gets below 10 mins your macro will be called once when you change a value in the spread sheet. If the counter is greater than 10 mins the macro will not be called.


regards

Kev
 
Upvote 0

Forum statistics

Threads
1,223,577
Messages
6,173,164
Members
452,504
Latest member
frankkeith2233

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