+ Reply to Thread
Results 1 to 11 of 11

Trying to get macro to reference newly copied worksheet

  1. #1
    Registered User
    Join Date
    12-17-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Trying to get macro to reference newly copied worksheet

    Hello all - I am trying to get my macro to copy one worksheet to a new worksheet, clear a few cells, and rename the sheet to the next consecutive number. I have been able to get the macro to do it properly the first time but when I try to reference the newly created sheet, it references the 1st sheet. What I would like to accomplish is have new sheet #2 reference sheet #1, new sheet #3 reference sheet #2, new sheet #4 reference sheet 3 and so on. These worksheets are in the middle of a workbook with about 10 sheets in it. Any help would be appreciated. This is what I have so far.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Trying to get macro to reference newly copied worksheet

    It's really easy to mess this up. So please clarify.

    The first time this runs it copies BITRUN 1 and places it before Sheet(6) and renames it BITRUN 2. What is Sheet(6) called?

    The next time this macro runs, it copies BITRUN 1 and places it before Sheet(6) again? Or should it be before sheet(7) this time? Is the placement variable, too? If so, what is the actual name of the sheet these new sheets should be going before?

    This would be much easier to do with sample workbook(s) demonstrating BEFORE/AFTER.
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    12-17-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trying to get macro to reference newly copied worksheet

    What I would like it to do is add another sheet right after the one it just made and keep doing that for as many sheets as necessary. Each bitrun sheet should be before the data assimilation sheet. Attached is the workbook I am working on. Thankyou for your reply.New Mud Pulse Job Paperwork V1.3.xlsm

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Trying to get macro to reference newly copied worksheet

    Try...
    Please Login or Register  to view this content.
    Last edited by dangelor; 12-29-2011 at 08:30 PM.

  5. #5
    Registered User
    Join Date
    12-17-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trying to get macro to reference newly copied worksheet

    Dude - Wow, that was good! Does exactly what I want. Have a great new year.

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Trying to get macro to reference newly copied worksheet

    Glad to help! I edited the sub. Had a small error. Recopy the new version.

  7. #7
    Registered User
    Join Date
    12-17-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trying to get macro to reference newly copied worksheet

    Actually just did a little playing around with the spreadsheet and it looks like the formula in cell I20 doesnt copy to the newly created sheets. Any ideas?

  8. #8
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Trying to get macro to reference newly copied worksheet

    See attached file
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-17-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trying to get macro to reference newly copied worksheet

    Looks really good but I would like to get the "end depth" from bitrun 2 to transfer to "start depth" on bitrun 3 and so on
    Also the "end inc" from bitrun 1 to transfer to "start inc" on bitrun 2 and so on
    And the "end date" from bitrun 1 to transfer to "start date" on bitrun 2 and so on

    Once again thankyou very much for your patience and time.

  10. #10
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Trying to get macro to reference newly copied worksheet

    Try...
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-17-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trying to get macro to reference newly copied worksheet

    Absolutely perfect!! I cant believe how much you condensed the code. Man do I have a lot to learn.

    Thank you so much!!

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