Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Selecting which macro to run based on a user entry

I want to be able to write a macro that when run looks at a user entry
(numeric) and based on that answer, runs a specific corresponding
macro.

Example:

User open the workbook and answers the prompted question with a 1 and
clicks the "submit" button. The macro looks at the answer (the 1) and
opens another workbook and runs macro 1. If however the user entered 9
then the macro would open the workbook and run macro 9.

Is there a way to do this?

I know how to open another workbook and run a macro from a macro. The
part I don't know is how to have the macro decide which macro in the
other workbook to run.

Any assistance is greatly appreciated.

Don

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Selecting which macro to run based on a user entry


ans = InputBox("Supply a number")
Select Case ans
Case 1
Workbooks.Open C"\book1.xls
Application.Run "'Book1.xls'!macro1"
Case 2
Workbooks.Open C"\book2.xls
Application.Run "'Book1.xls'!macro2"
'etc.
End Select

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
oups.com...
I want to be able to write a macro that when run looks at a user entry
(numeric) and based on that answer, runs a specific corresponding
macro.

Example:

User open the workbook and answers the prompted question with a 1 and
clicks the "submit" button. The macro looks at the answer (the 1) and
opens another workbook and runs macro 1. If however the user entered 9
then the macro would open the workbook and run macro 9.

Is there a way to do this?

I know how to open another workbook and run a macro from a macro. The
part I don't know is how to have the macro decide which macro in the
other workbook to run.

Any assistance is greatly appreciated.

Don



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Selecting which macro to run based on a user entry

On Oct 30, 1:39 pm, "Bob Phillips" wrote:
ans = InputBox("Supply a number")
Select Case ans
Case 1
Workbooks.Open C"\book1.xls
Application.Run "'Book1.xls'!macro1"
Case 2
Workbooks.Open C"\book2.xls
Application.Run "'Book1.xls'!macro2"
'etc.
End Select

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message

oups.com...



I want to be able to write a macro that when run looks at a user entry
(numeric) and based on that answer, runs a specific corresponding
macro.


Example:


User open the workbook and answers the prompted question with a 1 and
clicks the "submit" button. The macro looks at the answer (the 1) and
opens another workbook and runs macro 1. If however the user entered 9
then the macro would open the workbook and run macro 9.


Is there a way to do this?


I know how to open another workbook and run a macro from a macro. The
part I don't know is how to have the macro decide which macro in the
other workbook to run.


Any assistance is greatly appreciated.


Don- Hide quoted text -


- Show quoted text -


Bob,

You are going to think I'm an idiot but how does the macro know where
to pick the answer up from. I see you reference InputBox. What is
that or how to I the two together.

Perhaps it would help if i explained.

I run a daily report. When the user indicates the are completing the
report for Monday, it prompts to determine if they are beginning a new
business week. If they answer yes, it takes them to another page
which asks them to input some data. One of the questions they have to
answer is which fiscal year week are they running. This answer can be
anywhere from 1 to 52. Based on the answer they supply in that one
cell, I need to be able to run the macro for that week. There are a
number of other questions on the page but I need the macro to key to a
single answer.

I think I understand the rest of the macro, I just don't know how to
tie the InputBox reference to the correct cell.

Sorry for being so slow.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Selecting which macro to run based on a user entry

Maybe I misunderstood you, but you said wanted to look at user entry, which
I took to be some sort of active dialog, hence the Inputbox.



In this follow-up, you say it prompts for a new business week. Surely you
are using Inputbox for this, so you know how to integrate it.



If not, how are you determining the answers to all of these questions.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
ups.com...
On Oct 30, 1:39 pm, "Bob Phillips" wrote:
ans = InputBox("Supply a number")
Select Case ans
Case 1
Workbooks.Open C"\book1.xls
Application.Run "'Book1.xls'!macro1"
Case 2
Workbooks.Open C"\book2.xls
Application.Run "'Book1.xls'!macro2"
'etc.
End Select

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

wrote in message

oups.com...



I want to be able to write a macro that when run looks at a user entry
(numeric) and based on that answer, runs a specific corresponding
macro.


Example:


User open the workbook and answers the prompted question with a 1 and
clicks the "submit" button. The macro looks at the answer (the 1) and
opens another workbook and runs macro 1. If however the user entered 9
then the macro would open the workbook and run macro 9.


Is there a way to do this?


I know how to open another workbook and run a macro from a macro. The
part I don't know is how to have the macro decide which macro in the
other workbook to run.


Any assistance is greatly appreciated.


Don- Hide quoted text -


- Show quoted text -


Bob,

You are going to think I'm an idiot but how does the macro know where
to pick the answer up from. I see you reference InputBox. What is
that or how to I the two together.

Perhaps it would help if i explained.

I run a daily report. When the user indicates the are completing the
report for Monday, it prompts to determine if they are beginning a new
business week. If they answer yes, it takes them to another page
which asks them to input some data. One of the questions they have to
answer is which fiscal year week are they running. This answer can be
anywhere from 1 to 52. Based on the answer they supply in that one
cell, I need to be able to run the macro for that week. There are a
number of other questions on the page but I need the macro to key to a
single answer.

I think I understand the rest of the macro, I just don't know how to
tie the InputBox reference to the correct cell.

Sorry for being so slow.



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
Selecting a cell entry based on cell validation selection Brutalius Excel Worksheet Functions 2 December 17th 08 03:44 AM
Auto entry of data based on entry of text in another column or fie Judy Rose Excel Discussion (Misc queries) 2 May 21st 08 01:14 PM
Filter Excel Pivot, based on user entry form Jayco Excel Discussion (Misc queries) 1 August 16th 06 06:07 PM
Delete a Column Based on User Entry Anice Excel Programming 3 June 13th 06 02:54 PM
macro that brings user to cell based on "yes/no" response lennyx2 Excel Discussion (Misc queries) 2 February 9th 05 02:47 PM


All times are GMT +1. The time now is 08:43 PM.

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"