Excute commands that imported into array

Public Const Const1 = 1

The above can be put under (General) (Declarations) of a Model in Excel VBA.

If I set strCmd = "Public Const Const1 = 1", is there a way to run this command in strCmd? 

February 21st, 2015 12:06am

The line

Public Const Const1 = 1

is not a command, but a declaration. You cannot "run" it - for example, if you copy the above line into the Immediate window and press Enter, you'll get an error message.

You can use code to place code, including declarations, into a module - see http://www.cpearson.com/excel/vbe.aspx

Free Windows Admin Tool Kit Click here and download it now
February 22nd, 2015 7:08am

Hi,

Please see Mr. Hanss explanation first, and this is the forum to discuss questions and feedback for Microsoft Excel, if you have further question about VBA, I recommend you post the question to the MSDN forum for Excel

http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

George Zhao
TechNet Community Support

February 23rd, 2015 8:45pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics