Community discussion forum

How to run this Macro?

  • 2 years ago

    I have a macro, named macro1, which will pop up a screen and ask for selection in a input box. Since I have to repeat it hundred times, I intend to write another macro, by which I can run macro1 with specific selection number automatically.

    Two macros are in the different workbook. The code I have is :

    Application.Run ("filename.xla!Macro1")

    It works. But it still popup the screen and ask for the selection number. Anyone knows how to write the command with a specific number selection to skip the screen popup. For example,

    application.run ("filename.xla!Macro1", 2)

    And advice is greatly appreciated. Have a great day.

    Best,  

  • 2 years ago

    Hi,

    The macro by default is a sub that doesn't take any parameters. So you have to re-design it so it accepts a parameter (in your case the specific selection number). Then when you call it you have to send this number within your call. Try learning how to create a sub with parameters and if it didn't work post your macros and I will try to do it.

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback