PDA

View Full Version : Run a command stored in a variable



PaulH
03-07-2008, 09:42 AM
I would like to issue an Excel VBA command from an input box. Is there a way to issue the command from a variable or directly from the input box?
Some programs have ways to read commands from variables. I need a method or a work around. Please help
Thanks,
Paul

Bob Phillips
03-07-2008, 12:05 PM
Not really. If you had a set of a few discrete options you could have a Select Case to evaluate them and then act appropriately.

PaulH
03-07-2008, 12:23 PM
Looking for the ability to do a large number and edit command in the inputbox which is loaded from a command selected from a spreadsheet list.
Thanks anyway,
Paul

Bob Phillips
03-07-2008, 12:43 PM
Not really clear what that means.

PaulH
03-10-2008, 04:37 AM
I have about 200 commands that I may want to enter via an inputbox by setting the default from a list in a spreadsheet. You pick the command run a macro the inputbox comes up preloaded with the active cell and then you edit the command to suit the situaltion. When you okay the input box the command should issue and perform a task in the spreadsheet.
Hope this clears it up,
Paul

Bob Phillips
03-10-2008, 06:02 AM
That hasn't added anything beyond what you have already said.

What about my suggestion in #2?

Norie
03-10-2008, 07:23 AM
Paul

What are these 'commands'?

PaulH
03-11-2008, 04:20 AM
The commands are anything from range selects to Offset commands, copy, paste, add sheets etc. I am trying to use the list as a resource to teach the commands. Currently I have to copy paste them into a macro and run it to demonstrate the command. I'd like a simpler more efficient method. There are too many to use a case structure. Hope you can help!
Paul

PaulH
03-27-2008, 10:37 AM
my few discrete options would be 200 cases

mdmackillop
03-27-2008, 11:30 AM
Does this (http://www.vbaexpress.com/kb/getarticle.php?kb_id=250) help?

Trevor
03-27-2008, 11:32 AM
Paul you could try the Run shell command, but for the full path name, change that to a variable but perform a lookup procedure to fill that vareable with the path name then exicute , in theory it sounds like it will work

Trevor
03-27-2008, 11:34 AM
Mdmackillop, didn't see your post untill I posted, your way may work better :)

PaulH
04-01-2008, 06:45 AM
This is an example of what I have tried but commands don't run out of variables. I'd like to know more about the Shell command. I looked at it but couldn't get it to work. The commands are in column A of the spredsheet, notes are covering BCD and I try to set up the execution to react in column E if applicable. The command would be edited in the input box to specify the working parameters
Sample commands:
ActiveSheet.Range(“F70”).Value=Now()
ActiveCell.Interior.ColorIndex = 6
ActiveCell.Offset(0,29)=ActiveCell.Offset(-1,28)
ActiveCell.Offset(-1, 0).Font.Bold = True

Attempted code:
Private Function ExecCmd(mycommand)
mycommand = InputBox("select single executable command to execute offset 4 columns", "command", ActiveCell.Value)
End Function


Sub sglcmd()
mycommand = InputBox("select single executable command to execute offset 4 columns", "command", ActiveCell.Value)
mycommand
End Sub