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

  • Thread starter Thread starter QNiehausen
  • Start date Start date
Q

QNiehausen

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.
 
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?
 
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.
 
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.
 
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.
 
Thank you... this looks like it'll do it! And thanks for the quickness of
the reply, as well!

Bill
 
Thanks for the quickness of this reply... this looks like either solution
will work. Have a great night!

Bill
 
Back
Top