+ Reply to Thread
Results 1 to 8 of 8

copy Activesheet multiple times in same workbook, name from list

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    copy Activesheet multiple times in same workbook, name from list

    Okay, I'm tired of going through this manually. I KNOW there's gotta be an easier way!

    Situation: We have a worksheet formatted the way we want it for general use for a Program, or a Strategy, or whatever. The worksheet is great. Now, we need a different worksheet for each Strategy, Program, or whatever that we're working with that day, but different only in that it's named for that particular program,etc. So we have to make 10, 20, 100 copies of that worksheet in the same workbook, and rename each sheet as "Program 1", "Program 2", "Program 100", etc, and change the Header or title cell to the new name. What a pain!

    What I want is to copy the activesheet as many times as I have entries in my list, renaming each tab (and maybe a header in the worksheet) with the list name. Does anyone have a macro that'll do that?

    UPDATE: Never mind. Sometimes I just need to think it through. I looked back at an existing macro I'd made, and discovered it was easier to modify than I thought. Code is below if someone can find use for it. But it STILL doesn't add the header name. I'll try to come up with a solution for that if I can find the time.
    HTML Code: 
    Last edited by jomili; 11-01-2012 at 06:13 PM.

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

    Re: copy Activesheet multiple times in same workbook, name from list

    What do you mean by the 'header'?

    Is it actually the header or a cell on the worksheet?

    Where does the header come from?

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: copy Activesheet multiple times in same workbook, name from list

    It depends on the worksheet. Sometimes there's an actual header on the page (IE Header and Footer), sometimes there's just a cell (usually on the top row) that contains the worksheet title. Ideally I'd like to select either the header cell or tell the macro that there's an actual header (99.9% of the time it's the center header) and have the macro paste the Worksheet name there.

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

    Re: copy Activesheet multiple times in same workbook, name from list

    You can add a header with the shee nam like this.
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: copy Activesheet multiple times in same workbook, name from list

    So, in my current code, after the line
    Please Login or Register  to view this content.
    I add your code, and for each sheet added the Sheetname would go in the center header? If that works, sounds like all I need to do now is at the front of my macro ask the question,"Do you want the sheet name added to the center header?", and route the macro accordingly. Could I add some font criteria to the "CenterHeader" line?

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

    Re: copy Activesheet multiple times in same workbook, name from list

    Yes you can add formatting to the header but it is a little tricky, well I think it is anyway.

    Here's an example of the string you would use:

    .CenterHeader = "&""Arial,Regular""&12&A"

    This sets the font to be Arial, Regular and size 12.

    So I suppose the general syntax is kind of like this.
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: copy Activesheet multiple times in same workbook, name from list

    Sorry it's taken so long to get back. WAY too many distractions (I call that "my job").

    I had to make a change; "Sheets(Sheets.Count)." wasn't working, so changed it to "Activesheet". Also added some screenupdating code to speed it up. Other than that the code is roughly the same as before, but now adds a formatted title. Thanks so much Norie!

    Please Login or Register  to view this content.

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

    Re: copy Activesheet multiple times in same workbook, name from list

    It should be Sheets.Count, but ActiveSheet should work too.

+ 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