Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to call a procedure when a cell value changes?

Hi,

I have a formula in cell B49 that calculates based on certain inputs.
How can I trigger a procedure to fire when the value of calculation in B49
changes?

Also, how can I supress a dialog in a macro?

Thanks in advance,

Bojana
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default How to call a procedure when a cell value changes?

You have to catch the change of the precednts of the formula. You can not
directly catch the change of the calculated cell. Depending on what the
prcidents of the formula looked like I might use union and intersect to make
things easy something like... (Where the precidents are B1 and B48)

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Union(Range("B48"), Range("B1"))) Is Nothing Then
MsgBox "Tada"
End If
End Sub

As for the dialogues it depends what they are but

Application.DisplayAlerts = False
Application.DisplayAlerts = True

will turn alerts on and off if that is what you meant by dialogues.


--
HTH...

Jim Thomlinson


"Bojana" wrote:

Hi,

I have a formula in cell B49 that calculates based on certain inputs.
How can I trigger a procedure to fire when the value of calculation in B49
changes?

Also, how can I supress a dialog in a macro?

Thanks in advance,

Bojana

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default How to call a procedure when a cell value changes?

In the worksheet module:
Say B49 is dependent on A1, B1, C1
=========================================
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" or Target.Address = "$B$1" or Target.Address
= "$C$1"
' procedure to run
End If
End Sub
==========================================

There is also the calculate event, but I am not sure how to trap
a given cell change
=========================================
Private Sub Worksheet_Calculate()
' maybe you can find a way to compare the before and after value of B49
' (one way is to make this make put the value of B49 in another cell,
than

If Range("B49") < Range("AZ49") then
' run procedure

Range("AZ49").Value = Range("B49")
End If
End Sub
=========================================

to turn off Alerts - place this in any code:
========================
Application.DisplayAlerts = False
' your code
Application.DisplayAlerts = True
========================
hth
--
steveB

Remove "AYN" from email to respond
"Bojana" wrote in message
...
Hi,

I have a formula in cell B49 that calculates based on certain inputs.
How can I trigger a procedure to fire when the value of calculation in B49
changes?

Also, how can I supress a dialog in a macro?

Thanks in advance,

Bojana



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to call a procedure when a cell value changes?

It still does not work, probably because I am doing something wrong. I must
say I know very little of VB. I am not familiar with intersect, union etc. Is
there a place where I could read about it?

I have named all the cells that preceed my target cell (B49). If I read this
code well, if the value of one of the listed cells changes, procedure
Run_solve will be run.

What I am missing in the code below is any reference to my target cell (B49)

Here is what I have now:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Union(Range("C46"), Range("O46"), Range("U46"),
Range("AA46"), Range("AG46"), Range("AM46"), Range("AS46"))) Is Nothing Then
Run_solve
End If
End Sub

What do I need to change to make it work? Could someone please help?

Thanks

"STEVE BELL" wrote:

In the worksheet module:
Say B49 is dependent on A1, B1, C1
=========================================
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" or Target.Address = "$B$1" or Target.Address
= "$C$1"
' procedure to run
End If
End Sub
==========================================

There is also the calculate event, but I am not sure how to trap
a given cell change
=========================================
Private Sub Worksheet_Calculate()
' maybe you can find a way to compare the before and after value of B49
' (one way is to make this make put the value of B49 in another cell,
than

If Range("B49") < Range("AZ49") then
' run procedure

Range("AZ49").Value = Range("B49")
End If
End Sub
=========================================

to turn off Alerts - place this in any code:
========================
Application.DisplayAlerts = False
' your code
Application.DisplayAlerts = True
========================
hth
--
steveB

Remove "AYN" from email to respond
"Bojana" wrote in message
...
Hi,

I have a formula in cell B49 that calculates based on certain inputs.
How can I trigger a procedure to fire when the value of calculation in B49
changes?

Also, how can I supress a dialog in a macro?

Thanks in advance,

Bojana




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default How to call a procedure when a cell value changes?

I'm not to sharp with Intersect. But it asks the question: Is my range
(Target
included in the following range (the cells referenced by B49)
[check VBE Help to get more info]

But the idea is to use the Worksheet_Change event.
This fires every time any cell on the worksheet is manually edited.
Target is a range name attached to the changed cell.
If Target is equal to any one of the cells that B49 depends on than
do your thing.

--
steveB

Remove "AYN" from email to respond
"Bojana" wrote in message
...
It still does not work, probably because I am doing something wrong. I
must
say I know very little of VB. I am not familiar with intersect, union etc.
Is
there a place where I could read about it?

I have named all the cells that preceed my target cell (B49). If I read
this
code well, if the value of one of the listed cells changes, procedure
Run_solve will be run.

What I am missing in the code below is any reference to my target cell
(B49)

Here is what I have now:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Union(Range("C46"), Range("O46"),
Range("U46"),
Range("AA46"), Range("AG46"), Range("AM46"), Range("AS46"))) Is Nothing
Then
Run_solve
End If
End Sub

What do I need to change to make it work? Could someone please help?

Thanks

"STEVE BELL" wrote:

In the worksheet module:
Say B49 is dependent on A1, B1, C1
=========================================
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" or Target.Address = "$B$1" or
Target.Address
= "$C$1"
' procedure to run
End If
End Sub
==========================================

There is also the calculate event, but I am not sure how to trap
a given cell change
=========================================
Private Sub Worksheet_Calculate()
' maybe you can find a way to compare the before and after value of
B49
' (one way is to make this make put the value of B49 in another cell,
than

If Range("B49") < Range("AZ49") then
' run procedure

Range("AZ49").Value = Range("B49")
End If
End Sub
=========================================

to turn off Alerts - place this in any code:
========================
Application.DisplayAlerts = False
' your code
Application.DisplayAlerts = True
========================
hth
--
steveB

Remove "AYN" from email to respond
"Bojana" wrote in message
...
Hi,

I have a formula in cell B49 that calculates based on certain inputs.
How can I trigger a procedure to fire when the value of calculation in
B49
changes?

Also, how can I supress a dialog in a macro?

Thanks in advance,

Bojana






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
Call Procedure Ronbo Excel Programming 4 February 23rd 05 08:11 PM
Where else to look for procedure call Lulu Excel Programming 0 November 24th 04 03:07 PM
Where else to look for procedure call Lulu Excel Programming 2 November 24th 04 02:14 AM
call procedure bob Excel Programming 1 August 9th 03 12:40 AM
procedure won't call John Gittins Excel Programming 0 August 5th 03 08:17 PM


All times are GMT +1. The time now is 03:45 PM.

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

About Us

"It's about Microsoft Excel"