ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto execute a macro if a cell value=1 ? (https://www.excelbanter.com/excel-programming/316773-auto-execute-macro-if-cell-value%3D1.html)

Sven[_4_]

Auto execute a macro if a cell value=1 ?
 

Hi,
Thanks a lot for the assistance so far but I tried to enter the
following code but it doesn't work anyway. I have most probably done
something wrong but I cannot figure out what. The code looks as
follows:


Private Sub Worksheet_Change(ByVal Target As Range)
Set i = Application.Intersect(Target, Range("B3"))
If Not i Is Nothing And Target.Value = 1 Then MacroX
Application.OnTime Now + TimeValue("00:01:00"), "MacroX"
End Sub



What I'm looking for is:
Execute the macro called MacroX every 60 seconds if the value in cell
B3 equals 1 (The macro I have done is normally executed with a button
located in a sheet called MySheet)


--
Sven
------------------------------------------------------------------------
Sven's Profile: http://www.excelforum.com/member.php...fo&userid=9548
View this thread: http://www.excelforum.com/showthread...hreadid=219545


Bob Phillips[_6_]

Auto execute a macro if a cell value=1 ?
 
You don't say what is not working, but put the Ontime command at the end of
MacroX, so as to reset the timer on completion of the current run.

Take a look at http://www.cpearson.com/excel/ontime.htm for further
details.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sven" wrote in message
...

Hi,
Thanks a lot for the assistance so far but I tried to enter the
following code but it doesn't work anyway. I have most probably done
something wrong but I cannot figure out what. The code looks as
follows:


Private Sub Worksheet_Change(ByVal Target As Range)
Set i = Application.Intersect(Target, Range("B3"))
If Not i Is Nothing And Target.Value = 1 Then MacroX
Application.OnTime Now + TimeValue("00:01:00"), "MacroX"
End Sub



What I'm looking for is:
Execute the macro called MacroX every 60 seconds if the value in cell
B3 equals 1 (The macro I have done is normally executed with a button
located in a sheet called MySheet)


--
Sven
------------------------------------------------------------------------
Sven's Profile:

http://www.excelforum.com/member.php...fo&userid=9548
View this thread: http://www.excelforum.com/showthread...hreadid=219545





All times are GMT +1. The time now is 02:23 AM.

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