+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    03-19-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    run a macro from sheet1 in sheet2 button

    Hi,
    I have a macro defined on excel sheet1 (to save the sheet to a file) and want to
    run this macro from a command button on sheet2. I have tried adding:

    xlapp.Run "Sheet1!save"

    in the vba for the button but the vb interpreter says there is no object.

    Does anyone know if its possible to do this?

    Thanks

  2. #2
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: run a macro from sheet1 in sheet2 button

    Assuming the button is from the Forms Tool Box, right-click the command button and choose "Assign Macro" from the context menu. The dialog box should display the name of the macro in sheet1 (unless you have used "Private Sub" when creating the macro - in which case remove the word "Private", then assign the macro, then add "Private" back to the macro name.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,228

    Re: run a macro from sheet1 in sheet2 button

    If you know the name of the macro, even though it's a private sub you can manually type it into the Assign Macro window, as long as you type it accurately it will be accepted.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    03-19-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: run a macro from sheet1 in sheet2 button

    Thanks Palmetto your suggestion worked perfectly

  5. #5
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: run a macro from sheet1 in sheet2 button

    Glad to be of help.
    Please mark your thread as solved by going to the top of YOUR first post and clicking on Thread Tools, then Go Advanced and choose the [SOLVED] prefix.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0