+ Reply to Thread
Results 1 to 11 of 11

Merge two macros together to make them work with each other

  1. #1
    Registered User
    Join Date
    07-21-2015
    Location
    Melbourne, Australia
    MS-Off Ver
    MAC 2011
    Posts
    7

    Merge two macros together to make them work with each other

    Hi,

    I need to merge to Macros to work with each other.

    The first Macro grabs names in a cell range then makes new tab names with the names in those cells -

    Please Login or Register  to view this content.
    The other macro copies a sheet and all its data into a new sheet -

    Please Login or Register  to view this content.
    I need the macro to make a new sheet according to the names in the cell range, and copy into each of the new tab the data from sheet "Invoice", so one month i may have 8 names, then the next month may have 16 names.

    so for example if there is 8 cells to be made into 8 named tabs, then each of the 8 newly made tabs will have the same data from the sheet "Invoice"

    if there are 16 cells to be made into 16 named tabs, then each of the 16 newly made tabs will have the same data from the sheet "Invoice"

    Thank You in advance
    Last edited by alansidman; 04-03-2016 at 09:25 AM.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Merge two macros together to make them work with each other

    Try...
    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,705

    Re: Merge two macros together to make them work with each other

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    07-21-2015
    Location
    Melbourne, Australia
    MS-Off Ver
    MAC 2011
    Posts
    7

    Re: Merge two macros together to make them work with each other

    Thanks gmr4evr1 for the reply.

    Unfortunately it didn't work 100%.

    It will first add the new tabs and name them as in the cells, but will then ask to "Enter number of time to copy Sheet1" then it will add the that number of sheets between the main sheet (Address) and the newly name tabs.

    The copied sheet has the correct data in it, but the tabs are named incorrectly (Sheet (2), Sheet (3) etc) then the new tabs which are named correctly have no data in it the sheets.

    Have i missed a step?

    I want it to create the new named tabs, then know how many tabs were created and then copy and paste the data in Sheet 1 (i named it Invoice) into the the newly created named tabs. So if there were 8 new tabs names created it will know to copy and paste all the data in Sheet 1 (Invoice) in to all the new 8 named tabs.

    Hope this makes sense.

    Thanks.

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Merge two macros together to make them work with each other

    Hmm...when I run the code, it renames the sheets as Invoice(1), Invoice(2), Invoice(3) etc. But, I am running into the same problem with the correctly named sheets being blank.

  6. #6
    Registered User
    Join Date
    07-21-2015
    Location
    Melbourne, Australia
    MS-Off Ver
    MAC 2011
    Posts
    7

    Re: Merge two macros together to make them work with each other

    Yes, it is doing the same thing, Invoice(1), Invoice(2), Invoice(3) etc has the correct data, but the correctly named sheets are blank.

    Any ideas?

  7. #7
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Merge two macros together to make them work with each other

    You want the correctly named sheets to have the data as well as the invoice (1, 2, 3 etc.) sheets?

  8. #8
    Registered User
    Join Date
    07-21-2015
    Location
    Melbourne, Australia
    MS-Off Ver
    MAC 2011
    Posts
    7

    Re: Merge two macros together to make them work with each other

    I want the new correctly named sheets to have the same data as in the sheet Invoice.

    So if the cells in the sheet 'Address'
    A2 = 111 - Jones, A3 = 112 - Smith, A4 = 113 - Stevens
    then those new named sheets (111 - Jones,112 - Smith,113 - Stevens) will have all the data in the sheet named Invoice

    so the macro will need to know how many names are in the A2 range, make the new named sheets, then copy all the data in the sheet named Invoice into the all the new named sheets made.

    Hope this makes sense.

  9. #9
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Merge two macros together to make them work with each other

    Ok, I think I understand now...problem is, I'm not sure how to get there. I've tried a few things and they all do the same thing. I know I'm missing something but cant figure out what. I did however notice that in the first macro, MyRange is set twice before the code runs, I wonder if that is throwing it off.

  10. #10
    Registered User
    Join Date
    07-21-2015
    Location
    Melbourne, Australia
    MS-Off Ver
    MAC 2011
    Posts
    7

    Re: Merge two macros together to make them work with each other

    Found the solution.

    Please Login or Register  to view this content.
    Thanks

  11. #11
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Merge two macros together to make them work with each other

    I'm glad you got it worked out...sorry I wasn't more helpful.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Single macros to work on 2 files to merge, is it possible
    By dainova in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2014, 10:10 PM
  2. [SOLVED] How to make 2 macros work
    By aaron061883 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-05-2013, 10:15 PM
  3. Replies: 2
    Last Post: 07-31-2012, 04:22 PM
  4. how can i make macros to work when in tools, costumize and option.
    By MOLECULA0_0 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-17-2006, 11:54 PM
  5. Replies: 1
    Last Post: 05-02-2006, 12:45 PM
  6. make macros (sub) work for add-in?
    By meow@regretless.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2005, 11:25 PM
  7. Replies: 2
    Last Post: 11-11-2005, 02:25 AM
  8. How can I make Excel Macros created on PC work on Macintosh?
    By best_before in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-28-2005, 12:06 PM

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