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".
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".
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
>
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
>>
>
>
Norman
Works a treat
Many thanks
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
> >
>
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks