Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using a cell integer to select a macro
I would like to have a user enter an integer between 1 and 6 into a
cell, and then have one of six macros execute automatically depending on what integer was entered. (As an alternative, I could use a button to start the macro after the integer entered by telling the user to hit the button when done). I also hope to display an error message if an unacceptable integer is entered. I can probably figure this out if I keep at it long enough, but help is sure appreciated. Bob Q. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using a cell integer to select a macro
use a worksheet change event
sub worksheet_change(byval target as excel.range) 'target is the range that was changed 'first evaluate and make sure it is the right cell 'then select case target case 1 macro1 case 2 macro2 case 3 macro3 case 4 macro4 case 5 macro5 case 6 macro6 case else msgbox "Invalid entry" end select end sub -- When you lose your mind, you free your life. " wrote: I would like to have a user enter an integer between 1 and 6 into a cell, and then have one of six macros execute automatically depending on what integer was entered. (As an alternative, I could use a button to start the macro after the integer entered by telling the user to hit the button when done). I also hope to display an error message if an unacceptable integer is entered. I can probably figure this out if I keep at it long enough, but help is sure appreciated. Bob Q. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using a cell integer to select a macro
Have one macro with a case statement
Sub Selectmacro() Select Case Range("A1").Value Case 1 : Call macroA Case 2:: Call macroB 'etc. Case Else: Msgbox "Invalid Value" End Select End Sub -- HTH Bob Phillips wrote in message ups.com... I would like to have a user enter an integer between 1 and 6 into a cell, and then have one of six macros execute automatically depending on what integer was entered. (As an alternative, I could use a button to start the macro after the integer entered by telling the user to hit the button when done). I also hope to display an error message if an unacceptable integer is entered. I can probably figure this out if I keep at it long enough, but help is sure appreciated. Bob Q. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using a cell integer to select a macro
If you want to use a cell change - than use a worksheet change event macro
Say that you cell is A1 If target.Address = "$A$1" then if target = 1 then Macro1 elsif target = 2 then Marco2 elseif .... else msgbox "Incorrect Entry! Please try again" end if end if -- steveB Remove "AYN" from email to respond wrote in message ups.com... I would like to have a user enter an integer between 1 and 6 into a cell, and then have one of six macros execute automatically depending on what integer was entered. (As an alternative, I could use a button to start the macro after the integer entered by telling the user to hit the button when done). I also hope to display an error message if an unacceptable integer is entered. I can probably figure this out if I keep at it long enough, but help is sure appreciated. Bob Q. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using a cell integer to select a macro
Everything works! Thank you so very much.
Bob Q. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro - Select cell with no text | Excel Worksheet Functions | |||
Run a macro from cell select | Excel Discussion (Misc queries) | |||
Macro for cell select | Excel Discussion (Misc queries) | |||
macro select next blank cell in a row | Excel Programming | |||
Run Macro When Select Cell | Excel Programming |