Answer the question
In order to leave comments, you need to log in
How to write a macro that activates another macro, depending on a condition?
Google spreadsheets!
There is one cell, which is a drop-down list with 10 items.
Each item has a pre-recorded macro.
One button is required, which will activate a ready-made macro, which corresponds to its own item.
For example:
If cell a1=1, then activate macro1;
Otherwise, if cell a1=2, then activate macro2;
Otherwise, if cell a1=3, then activate macro3...
And so on.
Thank you!
Answer the question
In order to leave comments, you need to log in
A macro is a procedure
called from code as usual.
sub MyGlavniyMacros()
select case ActiveSheet.range("A1").value
case 1: call MySlaveMacros1()
case 2: call MySlaveMacros2()
case else : call MySlaveMacrosDefault()
end select
end sub
You can use the switch statement
function oneButtonMacros() {
switch (SpreadsheetApp.getRange('Sheet1!A1').getValue()) {
case 1:
macros1();
break;
case 2:
macros2();
break;
case 3:
macros3();
break;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question