=IF($A$11=1,"macro1","Macro2")
What is the code for the above if I want a respective macro -- in my example, macro 1 to run if A11 has a 1 and macro 2 to run if different value?
Thanks.
=IF($A$11=1,"macro1","Macro2")
What is the code for the above if I want a respective macro -- in my example, macro 1 to run if A11 has a 1 and macro 2 to run if different value?
Thanks.
Please Login or Register to view this content.
Last edited by AB33; 02-23-2013 at 04:18 PM.
OOPs and with acknowledgements to AB33 - just in case the shorthand/psuedo code confuses,
perhaps variations on the following
orPlease Login or Register to view this content.
orPlease Login or Register to view this content.
Please Login or Register to view this content.
Last edited by barryleajo; 02-23-2013 at 04:53 PM. Reason: typos
If this was helpful then please click the small star icon at the bottom left of my post. A little appreciation goes a long way.
Thanks --so can run a macro within an IF type function -- my actual situation is a somewhat more complicated -- have 6 choices for cell A11 -- 1a,1b,2a,2b,3a,3b. Depending on the contents of A11 a different macro is run. Can I do this and if so How?
Thanks again.
Perhaps a variation on this to suit your requirements?
Please Login or Register to view this content.
Last edited by barryleajo; 02-23-2013 at 04:50 PM. Reason: typo
The only way this really works is if "macro1" and "macro2" are written as user-defined functions (A VBA function procedure that is written so it can be called directly from an Excel cell like Excel's built in functions). UDF's can perform calculations and return values to the cell(s) they are called from, but they cannot perform actions like deleting, formatting, copying, etc. You haven't specified what "macro1" and "macro2" do. If they are computing a value so that they can be set up as UDFs, then you should be able to use them like you are suggesting. If they are doing other things, then you will need code like the other responses have suggested - your VBA procedure will have to test the condition and call macro1 and macro2 accordingly.=IF($A$11=1,"macro1","Macro2")
Originally Posted by shg
Hi,
I have read the reply and just wondered if the same expert can help me with similar enquiry:
If I want to copy cell A to a new line of a new worksheet when "option a" is selected/entered for cell B of the same record?
Await your advice,
thanks
Felicia, please start your own thread.
Entia non sunt multiplicanda sine necessitate
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks