Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Steen H. Pedersen
 
Posts: n/a
Default How do I run a Macro on basic of a value in a specific cell

ex.:
If A2=1 then run Macro "GetTime1"
  #2   Report Post  
Steen H. Pedersen
 
Posts: n/a
Default

Sorry -I forgot:
The Macro "GetTime" shuld copy a range of cells and place them at the row
where the Macro is called from

"Steen H. Pedersen" skrev:

ex.:
If A2=1 then run Macro "GetTime1"

  #3   Report Post  
Fadi Chalouhi
 
Posts: n/a
Default

Insert the following code in the worksheet_change macro of the relevant
worksheet :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" And Target.Value = "1" Then
' Run your macro
End If
End Sub

This assumes the following :
(1) the cell you are monitoring is A2 (make sure you put the $ in the
address)
(2) the value you are monitoring is 1
(3) you only want your macro to run when cell A2 gets modified to 1.
(4) if you want your macro to run every time anything changes in the
worksheet (and when cell A2 is 1) then remove the Target.Address
condition.

HTH

Fadi
www.chalouhis.com/XLBLOG

  #4   Report Post  
Steen H. Pedersen
 
Posts: n/a
Default

Thank You
This got me "over the hill"

Steen

"Fadi Chalouhi" skrev:

Insert the following code in the worksheet_change macro of the relevant
worksheet :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" And Target.Value = "1" Then
' Run your macro
End If
End Sub

This assumes the following :
(1) the cell you are monitoring is A2 (make sure you put the $ in the
address)
(2) the value you are monitoring is 1
(3) you only want your macro to run when cell A2 gets modified to 1.
(4) if you want your macro to run every time anything changes in the
worksheet (and when cell A2 is 1) then remove the Target.Address
condition.

HTH

Fadi
www.chalouhis.com/XLBLOG


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
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Visual Basic Macro negzel Excel Discussion (Misc queries) 1 December 28th 04 10:53 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM


All times are GMT +1. The time now is 08:14 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"