Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto execute a macro if a cell value=1 ?

Hi,
How does the VBA code looks like for the following?

Task:
Execute a macro called “MacroX” if cell B3=1

In other words: I would like to automatically run a macro calle
“MacroX” only if the cell B3 equals 1.00

Additional question:
Is it possible to set so that the macro run every 60 seconds if cell B
equals 1

Many thanks
Sve

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Auto execute a macro if a cell value=1 ?

use the worksheet change event

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 Macro
End sub

Why in the world would anyone want a Macro to run every 60 s.
I suggest you find another solution. Macros dont make good background processes

But i think u would need to do a recursive OnTime Method (look in VB help

----- Sven wrote: ----

Hi,
How does the VBA code looks like for the following

Task
Execute a macro called €śMacroX€ť if cell B3=

In other words: I would like to automatically run a macro calle
€śMacroX€ť only if the cell B3 equals 1.00

Additional question
Is it possible to set so that the macro run every 60 seconds if cell B
equals

Many thank
Sve


--
Message posted from http://www.ExcelForum.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto execute a macro if a cell value=1 ?

Thanks ~×

A agree that it may not be the most efficient way to do it but ho
would you incorporate this into the answer you gave?

For example that the macro is executed over and over again with a
interval every 60 seconds until cell B3 is not equal to 1

Thanks,
Sve

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Auto execute a macro if a cell value=1 ?

'inside MacroX put this in as the first statemen
If Sheets("YourSheet").Range("b3") < 1 Then Exit Su

'put this in as the last statement,
Application.OnTime Now + TimeValue("00:01:00"), "MacroX

'this will cause a recursive execution of the macro as long as Range("B3")=
'I did it this way because i don't know how long your Macro will run for
'else do it like this: as first statemen

If Sheets("YourSheet").Range("b3") = 1 The
Application.OnTime Now + TimeValue("00:01:00"), "MacroX
End If

'I make no promises with the OnTime Method, so good luck
----- Sven wrote: ----

Thanks ~Ă

A agree that it may not be the most efficient way to do it but ho
would you incorporate this into the answer you gave

For example that the macro is executed over and over again with a
interval every 60 seconds until cell B3 is not equal to

Thanks
Sve


--
Message posted from http://www.ExcelForum.com


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Execute Macro dennis[_2_] Excel Discussion (Misc queries) 4 January 17th 09 04:47 PM
Auto Execute Macro dennis[_2_] Excel Worksheet Functions 4 January 17th 09 04:47 PM
How do I execute a macro based on the value of a cell in Excel? brettopp Excel Discussion (Misc queries) 12 June 17th 06 01:27 AM
Auto-execute macro.... Eric @ SEASH, Evansville Excel Discussion (Misc queries) 1 August 24th 05 09:32 PM
Execute VBA macro whilst editing a cell Melandra Excel Programming 1 January 28th 04 01:07 PM


All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"