+ Reply to Thread
Results 1 to 5 of 5

Initialize macro

  1. #1
    Registered User
    Join Date
    10-30-2005
    Posts
    3

    Initialize macro

    How do I initialize a macro to run when a cell value changes, the target cell contains a reference formula, with either a "0" or "1" as the result, IU want the macro to start when the result is "1".

  2. #2
    Norman Jones
    Guest

    Re: Initialize macro

    Hi Tom,

    Try:
    '============>>
    Private Sub Worksheet_Calculate()
    If Range("A1") = 1 Then
    Call MyMacro
    End If
    End Sub

    '<<============

    This is worksheet event code and should be pasted into the worksheets's code
    module (not a standard module and not the workbook's ThisWorkbook module):

    *******************************************
    Right-click the worksheet's tab

    Select 'View Code' from the menu and paste the code.

    Alt-F11 to return to Excel.
    *******************************************

    ---
    Regards,
    Norman



    "Tom Jung" <Tom.Jung.1xquuc_1130724303.6726@excelforum-nospam.com> wrote in
    message news:Tom.Jung.1xquuc_1130724303.6726@excelforum-nospam.com...
    >
    > How do I initialize a macro to run when a cell value changes, the target
    > cell contains a reference formula, with either a "0" or "1" as the
    > result, IU want the macro to start when the result is "1".
    >
    >
    > --
    > Tom Jung
    > ------------------------------------------------------------------------
    > Tom Jung's Profile:
    > http://www.excelforum.com/member.php...o&userid=28448
    > View this thread: http://www.excelforum.com/showthread...hreadid=480486
    >




  3. #3
    Norman Jones
    Guest

    Re: Initialize macro

    Hi Tom,

    I should add, change A1 to your cell of interest.


    ---
    Regards,
    Norman



    "Norman Jones" <normanjones@whereforartthou.com> wrote in message
    news:Ofz%23nDc3FHA.1416@TK2MSFTNGP09.phx.gbl...
    > Hi Tom,
    >
    > Try:
    > '============>>
    > Private Sub Worksheet_Calculate()
    > If Range("A1") = 1 Then
    > Call MyMacro
    > End If
    > End Sub
    >
    > '<<============
    >
    > This is worksheet event code and should be pasted into the worksheets's
    > code module (not a standard module and not the workbook's ThisWorkbook
    > module):
    >
    > *******************************************
    > Right-click the worksheet's tab
    >
    > Select 'View Code' from the menu and paste the code.
    >
    > Alt-F11 to return to Excel.
    > *******************************************
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Tom Jung" <Tom.Jung.1xquuc_1130724303.6726@excelforum-nospam.com> wrote
    > in message news:Tom.Jung.1xquuc_1130724303.6726@excelforum-nospam.com...
    >>
    >> How do I initialize a macro to run when a cell value changes, the target
    >> cell contains a reference formula, with either a "0" or "1" as the
    >> result, IU want the macro to start when the result is "1".
    >>
    >>
    >> --
    >> Tom Jung
    >> ------------------------------------------------------------------------
    >> Tom Jung's Profile:
    >> http://www.excelforum.com/member.php...o&userid=28448
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=480486
    >>

    >
    >




  4. #4
    Registered User
    Join Date
    10-30-2005
    Posts
    3
    Norman
    Works a treat
    Many thanks

  5. #5
    David
    Guest

    Re: Initialize macro

    What if I want to start the macro just by changing a letter in the cell, such
    as Y or N?

    "Norman Jones" wrote:

    > Hi Tom,
    >
    > Try:
    > '============>>
    > Private Sub Worksheet_Calculate()
    > If Range("A1") = 1 Then
    > Call MyMacro
    > End If
    > End Sub
    >
    > '<<============
    >
    > This is worksheet event code and should be pasted into the worksheets's code
    > module (not a standard module and not the workbook's ThisWorkbook module):
    >
    > *******************************************
    > Right-click the worksheet's tab
    >
    > Select 'View Code' from the menu and paste the code.
    >
    > Alt-F11 to return to Excel.
    > *******************************************
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Tom Jung" <Tom.Jung.1xquuc_1130724303.6726@excelforum-nospam.com> wrote in
    > message news:Tom.Jung.1xquuc_1130724303.6726@excelforum-nospam.com...
    > >
    > > How do I initialize a macro to run when a cell value changes, the target
    > > cell contains a reference formula, with either a "0" or "1" as the
    > > result, IU want the macro to start when the result is "1".
    > >
    > >
    > > --
    > > Tom Jung
    > > ------------------------------------------------------------------------
    > > Tom Jung's Profile:
    > > http://www.excelforum.com/member.php...o&userid=28448
    > > View this thread: http://www.excelforum.com/showthread...hreadid=480486
    > >

    >
    >
    >


+ 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