ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I Get a String... or any variable for that matter? (https://www.excelbanter.com/excel-programming/415757-how-do-i-get-string-any-variable-matter.html)

QNiehausen

How do I Get a String... or any variable for that matter?
 
With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.

JLGWhiz

How do I Get a String... or any variable for that matter?
 
After looking at your posting again, I am not sure that I really understood
what you were asking. Could you give an example of how you would use such a
command?


"QNiehausen" wrote:

With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.


QNiehausen

How do I Get a String... or any variable for that matter?
 
thank you, but a "call" is the first step ~after~ the value has been
grabbed/picked. I need something that displays a dialog box of some sort
asking the user which direction he wants the macro to continue. It's got to
be some sort of "get" procedure or method.

"JLGWhiz" wrote:

How about "Call"?

"QNiehausen" wrote:

With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.


smartin

How do I Get a String... or any variable for that matter?
 
QNiehausen wrote:
With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.


Hi Q,

Sounds like a job for a combobox. Create a standard module, in this add
a form with a combobox and a command button. Add something like this to
the module code:

Private Sub UserForm_Initialize()
ComboBox1.AddItem "Run Evens Only"
ComboBox1.AddItem "Run Odds Only"
End Sub

Private Sub CommandButton1_Click()
Select Case ComboBox1.Value
Case "Run Evens Only"
MsgBox "Run Evens"
Case "Run Odds Only"
MsgBox "Run Odds"
Case Else
MsgBox "Nothing selected"
End Select
End Sub


JLGWhiz

How do I Get a String... or any variable for that matter?
 
How about "Call"?

"QNiehausen" wrote:

With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.


QNiehausen

How do I Get a String... or any variable for that matter?
 
Sure. I currently have a macro that runs 70 scenarios, 35 for each of two
clients. Sometimes the results require a little tweaking for either client's
data, and then I run the macro again. However, it takes about five seconds
per scenario, which leaves a waiting time of almost 5 minutes per cycle.
If I only need to run the new numbers of one of the clients, it can cut the
time in half. So, I'm trying to find a way to stop the macro with a dialog
box that asks if I want to run Client1, Client2 or Both. From that answer, I
can easily write in an If-Then or a Call to branch off in the proper
direction. Problem is, I'm going nuts trying to find the way to do it.

"JLGWhiz" wrote:

After looking at your posting again, I am not sure that I really understood
what you were asking. Could you give an example of how you would use such a
command?


"QNiehausen" wrote:

With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.


JLGWhiz

How do I Get a String... or any variable for that matter?
 
If you only have two choices you could use a message box with a Yes/No option.

Choice = MsgBox("Click Yes for Client 1, No for Client 2, Cancel for both", _
vbYes?No, "Choose Scenario")
If Choice = vbYes Then
Call Scenario1
ElseIf Choice = vbNo Then
Call Scenario2
Else
Call Scenario3
End If

Otherwise, if there are more scenarios then maybe a UserForm with a ListBox
would work. The UserForm will pause the macro, just like the message box,
until a selection is made from the list box and the subsequent code executes
to return to the main macro.






"QNiehausen" wrote:

Sure. I currently have a macro that runs 70 scenarios, 35 for each of two
clients. Sometimes the results require a little tweaking for either client's
data, and then I run the macro again. However, it takes about five seconds
per scenario, which leaves a waiting time of almost 5 minutes per cycle.
If I only need to run the new numbers of one of the clients, it can cut the
time in half. So, I'm trying to find a way to stop the macro with a dialog
box that asks if I want to run Client1, Client2 or Both. From that answer, I
can easily write in an If-Then or a Call to branch off in the proper
direction. Problem is, I'm going nuts trying to find the way to do it.

"JLGWhiz" wrote:

After looking at your posting again, I am not sure that I really understood
what you were asking. Could you give an example of how you would use such a
command?


"QNiehausen" wrote:

With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.


QNiehausen

How do I Get a String... or any variable for that matter?
 
Thank you... this looks like it'll do it! And thanks for the quickness of
the reply, as well!

Bill

"smartin" wrote:

QNiehausen wrote:
With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.


Hi Q,

Sounds like a job for a combobox. Create a standard module, in this add
a form with a combobox and a command button. Add something like this to
the module code:

Private Sub UserForm_Initialize()
ComboBox1.AddItem "Run Evens Only"
ComboBox1.AddItem "Run Odds Only"
End Sub

Private Sub CommandButton1_Click()
Select Case ComboBox1.Value
Case "Run Evens Only"
MsgBox "Run Evens"
Case "Run Odds Only"
MsgBox "Run Odds"
Case Else
MsgBox "Nothing selected"
End Select
End Sub



QNiehausen

How do I Get a String... or any variable for that matter?
 
Thanks for the quickness of this reply... this looks like either solution
will work. Have a great night!

Bill

"JLGWhiz" wrote:

If you only have two choices you could use a message box with a Yes/No option.

Choice = MsgBox("Click Yes for Client 1, No for Client 2, Cancel for both", _
vbYes?No, "Choose Scenario")
If Choice = vbYes Then
Call Scenario1
ElseIf Choice = vbNo Then
Call Scenario2
Else
Call Scenario3
End If

Otherwise, if there are more scenarios then maybe a UserForm with a ListBox
would work. The UserForm will pause the macro, just like the message box,
until a selection is made from the list box and the subsequent code executes
to return to the main macro.






"QNiehausen" wrote:

Sure. I currently have a macro that runs 70 scenarios, 35 for each of two
clients. Sometimes the results require a little tweaking for either client's
data, and then I run the macro again. However, it takes about five seconds
per scenario, which leaves a waiting time of almost 5 minutes per cycle.
If I only need to run the new numbers of one of the clients, it can cut the
time in half. So, I'm trying to find a way to stop the macro with a dialog
box that asks if I want to run Client1, Client2 or Both. From that answer, I
can easily write in an If-Then or a Call to branch off in the proper
direction. Problem is, I'm going nuts trying to find the way to do it.

"JLGWhiz" wrote:

After looking at your posting again, I am not sure that I really understood
what you were asking. Could you give an example of how you would use such a
command?


"QNiehausen" wrote:

With VB, I've used the GetOpenFilename and GetSaveAsFilename methods to
acquire text strings to be used for other parts of my scripts, but I can't
find a simple "Get" method that simply allows the user to select from a list
of strings to determine the course of the macro to continue. Y'know, like
"Select an Option"--"Run Evens Only","Run Odds Only","Run Both". That's it.
I've wasted hours searching through an 867-page manual and can't find
anything. "InputBox" method comes close, but it asks for the string to be
typed in. I need the input option to be a pre-defined list, or even buttons.
Is there a key word I'm missing? I've looked under "get", "acquire",
"select", "choose", "pick". Please help.



All times are GMT +1. The time now is 02:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com