Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
THW
 
Posts: n/a
Default Starting a macro with the IF function

Hi there,

is there any way to start a macro, once the contition of the if-function in
the worksheet turns true???

greetings and thankst

THW
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

No, but you could use event code to monitor the cell

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$1" Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
HTH

Bob Phillips

"THW" wrote in message
...
Hi there,

is there any way to start a macro, once the contition of the if-function

in
the worksheet turns true???

greetings and thankst

THW



  #3   Report Post  
dominicb
 
Posts: n/a
Default


Good afternoon Thw

A cell cannot kick off a macro, but you could use an event procedure to
do something when the cell changes - paste this code into your worksheet
event pane and replace my msgbox with your code. And remember that my
code is checking for the value of cell A1 being false - your post
doesn't state which cell you want to watch.

Private Sub Worksheet_Calculate()
If Range("A1") = True Then
MsgBox "Cell A1 is true."
End If
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=380107

  #4   Report Post  
THW
 
Posts: n/a
Default

hi dominicb

thank you for your reply, but my problem is not to be notified if the value
of a cell IS true, i need to be notified WHEN it's value changes to true

greetings
THW

"dominicb" wrote:


Good afternoon Thw

A cell cannot kick off a macro, but you could use an event procedure to
do something when the cell changes - paste this code into your worksheet
event pane and replace my msgbox with your code. And remember that my
code is checking for the value of cell A1 being false - your post
doesn't state which cell you want to watch.

Private Sub Worksheet_Calculate()
If Range("A1") = True Then
MsgBox "Cell A1 is true."
End If
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=380107


  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

I'll try again specifically

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$1" Then
With Target
if .value then
Msgbox "true"
endif
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

"THW" wrote in message
...
hi dominicb

thank you for your reply, but my problem is not to be notified if the

value
of a cell IS true, i need to be notified WHEN it's value changes to true

greetings
THW

"dominicb" wrote:


Good afternoon Thw

A cell cannot kick off a macro, but you could use an event procedure to
do something when the cell changes - paste this code into your worksheet
event pane and replace my msgbox with your code. And remember that my
code is checking for the value of cell A1 being false - your post
doesn't state which cell you want to watch.

Private Sub Worksheet_Calculate()
If Range("A1") = True Then
MsgBox "Cell A1 is true."
End If
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile:

http://www.excelforum.com/member.php...o&userid=18932
View this thread:

http://www.excelforum.com/showthread...hreadid=380107




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
NETWORKDAY function problem - starting on weekends [email protected] Excel Discussion (Misc queries) 5 June 16th 05 10:55 PM
Macro - define cell range for a sum function Fad Excel Discussion (Misc queries) 2 June 6th 05 12:40 PM
Find function in a macro Natalie Excel Worksheet Functions 4 March 22nd 05 07:27 PM
Function Macro for Nested IF Qaspec Excel Worksheet Functions 5 March 10th 05 07:25 PM
How Do I (Macro Function)? Swivel Excel Worksheet Functions 1 November 3rd 04 12:21 AM


All times are GMT +1. The time now is 06:59 PM.

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"