![]() |
Run macro whenever cell changes
Hi
Need help with macro The question is... how to run macro each time when cell changes but as result of formula calculation (mean without selection this cell) Example : I wish to run macro when value in cell A1 is changed by changing value in B1 (formula in A1 =B1) Thanks eLaCiD |
Run macro whenever cell changes
I am not sure If I get your question. B1 is = the value of A1? Why would you need a macro change that? Just make sure you have automatic calculation on. -- Bearacade ------------------------------------------------------------------------ Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016 View this thread: http://www.excelforum.com/showthread...hreadid=547906 |
Run macro whenever cell changes
Paste this code in the appropriate sheet...
Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range On Error Resume Next Set rng = Intersect(Target, Range("A1").Precedents) On Error GoTo 0 If Not rng Is Nothing Then MsgBox "Tada" End If End Sub -- HTH... Jim Thomlinson "eLaCiD" wrote: Hi Need help with macro The question is... how to run macro each time when cell changes but as result of formula calculation (mean without selection this cell) Example : I wish to run macro when value in cell A1 is changed by changing value in B1 (formula in A1 =B1) Thanks eLaCiD |
Run macro whenever cell changes
Hi eLaCiD,
Try something like: '============= Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range Set rng = Range("A1") If Not Intersect(rng.Precedents, Target) Is Nothing Then Call myMacro End If End Sub '<<============= --- Regards, Norman "eLaCiD" wrote in message ... Hi Need help with macro The question is... how to run macro each time when cell changes but as result of formula calculation (mean without selection this cell) Example : I wish to run macro when value in cell A1 is changed by changing value in B1 (formula in A1 =B1) Thanks eLaCiD |
Run macro whenever cell changes
Hi eLaCiD,
To allow for the posiibility that the range of interest does not have precedent cells, an error handler should be included - as in Jim's superior suggestion. --- Regards, Norman |
Run macro whenever cell changes
Realy fast :))
Thanks ... eLaCiD |
All times are GMT +1. The time now is 04:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com