Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a Macro From a Cell 2

Status
Not open for further replies.

jsaliers

Programmer
Jan 23, 2003
129
US
Here's what I need. I have a target cell A2, a compare cell B2, and a macro call cell C2. To start, A2 = B2. Eventually, B2 will be changed. I want to set up C2 to call a macro I already wrote (&quot;test_macro&quot;) when A2<>B2. I tried the following formula in C2:

=IF(A2<>B2,CALL(&quot;kernel32&quot;,&quot;test_macro&quot;,II))

Not sure if the call function will work, or if the syntax is correct. I couldn't make heads or tails of the help on the CALL_worksheet_function.

Any help will be much appreciated! Thanks in advance.

Jon
 
Alright, got it to work!!

Thank you both so much. You guys have been very helpful!

Jon
 
Got a quick question for you about this again. The excel sheet is being updated using DDE. Depending on the state of a PLC, the target cell(A2) will either be a 0 or a 1. However, the user will not be keying the change. When the change is made using DDE, will this trigger the worksheet_change event?

Jon
 
I just did a quick test and the answer appears to be yes, the Worksheet_Change event is fired.

Note also that depending on how much control you have at the client side, you can execute a macro directly with this command:
[blue]
Code:
   [Run(&quot;Macro_Name&quot;)]
[/color]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top