+ Reply to Thread
Results 1 to 6 of 6

Run macro whenever cell changes

  1. #1
    eLaCiD
    Guest

    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



  2. #2
    Forum Contributor
    Join Date
    06-01-2006
    Posts
    324
    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.

  3. #3
    Jim Thomlinson
    Guest

    RE: 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
    >
    >
    >


  4. #4
    Norman Jones
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >
    >




  5. #5
    Norman Jones
    Guest

    Re: 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



  6. #6
    eLaCiD
    Guest

    Re: Run macro whenever cell changes

    Realy fast )
    Thanks ...


    eLaCiD



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1