+ Reply to Thread
Results 1 to 18 of 18

Combine Multiple Macros

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Combine Multiple Macros

    Hi All,

    I was wondering if there was a way to combine macros? i have 3 separate macros that work quite well individually. I want to make a button to run the 3 in sequence but when i try to create a macro to fire them one after the other it wouldn't get past the 1st one. i was wondering if there was a way to combine each one in to one module.

    Any help will be muchly appreciated.

    Thanks
    Sean

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine Multiple Macros

    Why dont you post them here ?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Re: Combine Multiple Macros

    Oh Yea, it might help eh XD

    1st i want it to save using cell value.

    Please Login or Register  to view this content.
    2nd i want it to replace all the formula on sheet2 with there actual values.

    Please Login or Register  to view this content.
    Then i want it to save sheet 2 on its own. (i just replaced this one with the code you helped me with before the one i was using was saving all the sheets individually, i only needed sheet2)

    Please Login or Register  to view this content.
    Would this be possible to combine?
    Last edited by arlu1201; 04-11-2013 at 07:52 AM.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine Multiple Macros

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. In order to put code tags, either type [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] at the end of it, OR you can highlight your code and click the # icon at the top of your post window.

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine Multiple Macros

    Since we are saving the file twice with 2 different names, whenever we use the range or sheet comments, its better to name the workbook and the sheet along with it. For e.g. if we are referring to a worksheet, we name the workbook as well. If we are referring to a range, we name the workbook and the sheet to which it pertains. This ensures that the macro works correctly and only on the workbooks we need.

    So please provide the workbook names for each code.

  6. #6
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Re: Combine Multiple Macros

    Sorry i will do that in my future posts.

    Workbook? If you mean the actual file its self it has a name (M+M FINAL PACKING LIST SOLIDS)
    also the worksheets have been renamed to MASTER SOLIDS and FINAL SOLIDS.

    If you dont mean like that how would i rename it?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Run the code for copying Sheet2 first, do the copy and paste special on the worksheet in the newly created workbook, save the new workbook and add code to close it.

    Then run the code to save the original workbook.
    If posting code please use code tags, see here.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine Multiple Macros

    I meant to add the names in the code.

  9. #9
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Re: Combine Multiple Macros

    The codes are all for the same workbook and should affect the different worksheets. The workbook is called M+M FINAL PACKING LIST SOLIDS (should i change it and put underscores instead of spaces?)and the worksheets are called MASTER SOLIDS and FINAL SOLIDS.

  10. #10
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Re: Combine Multiple Macros

    it has to be done in this order from this workbook. It needs to be allocated to a button on the master page so when the user adds a packing list they have dont have any extra work to do but press the finish button.

  11. #11
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Re: Combine Multiple Macros

    Quote Originally Posted by Norie View Post
    Run the code for copying Sheet2 first, do the copy and paste special on the worksheet in the newly created workbook, save the new workbook and add code to close it.

    Then run the code to save the original workbook.
    It has to be done in this order from this workbook. It needs to be allocated to a button on the master page so when the user adds a packing list they have dont have any extra work to do but press the finish button.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combine Multiple Macros

    Why does it need to get done in a specific order?

    If you do it the way I suggest you'll end up with the exact same result.

  13. #13
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Re: Combine Multiple Macros

    Quote Originally Posted by Norie View Post
    Why does it need to get done in a specific order?

    If you do it the way I suggest you'll end up with the exact same result.
    Because we dont want to have to do anything with the workbook we will be creating. unless you mean write it so it happens all from the one click in the 1st workbook? If so could you show tell me how to do it please?

    Again im new to vba and macros etc. so im sorry if im coming across as quite slow, please be patient :D

  14. #14
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Re: Combine Multiple Macros

    Quote Originally Posted by arlu1201 View Post
    I meant to add the names in the code.
    The codes are all for the same workbook and should affect the different worksheets. The workbook is called M+M FINAL PACKING LIST SOLIDS (should i change it and put underscores instead of spaces?)and the worksheets are called MASTER SOLIDS and FINAL SOLIDS.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combine Multiple Macros

    Sean

    Everything would be done from the original workbook with something like this.
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    04-08-2013
    Location
    Wajdušna
    MS-Off Ver
    Office 365
    Posts
    79

    Re: Combine Multiple Macros

    Hello i have similar question, I have a workbook with 8 different sheets. Cuz i dont know hot to write code in VBA, I recorded 8 macros for each individual sheet. What the macro does is gathers the wanted data from that sheets and prints it. And it works great individually. But i have to press 8 buttons to get 8 different .pdf files and then combine them, and there is a lot of the code that is the same in every macro.
    Is any of you willing to take a look at my code and rearrange it so that it will took only one press of a button to print the wanted data from all the sheets?
    Here is a link to my word.doc that contains all 8 macros: https://dl.dropboxusercontent.com/u/...%20Makro1.docx
    Last edited by ATOP; 04-11-2013 at 10:45 AM. Reason: mistake

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combine Multiple Macros

    Welcome to the Forum.

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

  18. #18
    Registered User
    Join Date
    04-11-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2007/10
    Posts
    19

    Re: Combine Multiple Macros

    All sorted now, my friend gave the sheet a tinker over the weekend and it all works fine now

    Sorry for being a bother and thanks for the help, it was much appreciated

    Sean

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.6.0 RC 1