running a module

  • Hi all,

    I have been given this code by a friend but i do not want it to always look in this sheet.

    I have saved the module (send_rows) on a new spreadsheet.

    How can i just make it run from a button in whatever sheet it is in?

    I.e aslong as send_rows is saved in the modules of a spreadsheet i can run it!

    Sub LocalUse_Button2_Click()
    Application.Run "'GL Maintenance Systemv2.xls'!Send_rows.Send_rows"
    End Sub

  • Hi,

    if you want to call a global macro, you should place this macro in a module. The macro has to start with public.

    To call the macro:

    Application.Run "GL Maintenance Systemv2.xls!Send_rows"

    (Send_Rows is the macro name)


  • Hi,

    can you upload the workbook or a little example.
    I'm not sure what the problem is.

    The macro is in GL Maintenance Systemv2.xls.
    You open book1.xls and you want to run the macro from GL Maintenance Systemv2.xls but you want that the code applies to your active workbook(book1.xls)?

    Is this what you want to do? (Or does everything happens in the same workbook?)


  • what basically happens is.............

    The gl maintenancev2 has the module but my macros saves the sheet to a variable name which is never the same hence, i need it to work in the active worksheet.

    Is that possible as the name of the spreadsheet will never be the same !!:)

  • Hi,

    if you want to call the macro and you putted in a public module, it doesn't matter which sheet you are on. You can call it from every place in your workbook.

    If the macro selects a sheet you must check it the macro selects on the name or the index. => it depends on what the macro does.

    Basically: if you have a macro in a public module it should run anywhere in your excel-file


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!