Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Using a cell integer to select a macro

Everything works! Thank you so very much.

Bob Q.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro - Select cell with no text Dileep Chandran Excel Worksheet Functions 3 December 6th 06 06:01 AM
Run a macro from cell select famdamly Excel Discussion (Misc queries) 3 March 3rd 06 03:51 PM
Macro for cell select comotoman Excel Discussion (Misc queries) 5 October 14th 05 10:06 PM
macro select next blank cell in a row raph_baril Excel Programming 2 June 2nd 05 07:50 PM
Run Macro When Select Cell Andibevan[_2_] Excel Programming 1 March 18th 05 12:00 PM


All times are GMT +1. The time now is 09:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"