Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have written 6 macros and want to choose to use 1 of them depending upon
the value of “n” in cell A1 If “n” = 1 through 20 use Macro 1 If “n” = 21 through 40 use Macro 2 If “n” = 41 through 60 use Macro 3 If “n” = 61 through 80 use Macro 4 If “n” = 81 through 100 use Macro 5 If “n” = 100 use Macro 6 Is this possible?? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
use a case statement
Select case n case 1 to 20 macro1 case 21 to 40 macro2 End Select -- Regards, Tom Ogilvy "Rob947" wrote in message lkaboutsoftware.com... I have written 6 macros and want to choose to use 1 of them depending upon the value of "n" in cell A1 If "n" = 1 through 20 use Macro 1 If "n" = 21 through 40 use Macro 2 If "n" = 41 through 60 use Macro 3 If "n" = 61 through 80 use Macro 4 If "n" = 81 through 100 use Macro 5 If "n" = 100 use Macro 6 Is this possible?? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() You practically have the code written already. Sub RunMacro() If n <= 20 Then Macro1 If n = 21 And n <= 40 Then Macro2 If n = 41 And n <= 60 Then Macro3 If n = 61 And n <= 80 Then Macro4 If n = 81 And n <= 100 Then Macro 5 If n = 101 Then Macro6 End Sub If you expect non integer values for n then you will want to replace either the less than or equal to, or the greater than or equal to in each If statement to simply less than, or greater than (depending on how you want the variable treated). HTH -- bhofsetz ------------------------------------------------------------------------ bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807 View this thread: http://www.excelforum.com/showthread...hreadid=375284 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sum cells based on a row variable and seperate column variable | Excel Worksheet Functions | |||
listing values to choose from based on value in another cell | Excel Discussion (Misc queries) | |||
Choose data from a particular column based on a specific value | Excel Worksheet Functions | |||
Run MACRO from the valve of a cell? | Excel Programming | |||
How to pass valve in combobox object to cell | Excel Programming |