+ Reply to Thread
Results 1 to 10 of 10

I need a macro which will add sheets using a template and name them from a column of cells

  1. #1
    Registered User
    Join Date
    02-04-2014
    Location
    Big Spring, Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Cool I need a macro which will add sheets using a template and name them from a column of cells

    Hi everyone, I'm new here and don't have a lot of experience with macros but here is my problem.

    Step 1: I have data coming from a data dump which is placed on the "Summary" sheet of my excel workbook. I need to take column A (beginning at A8) and create a new sheet (based on "Template" located in the same workbook) for each name in column A.

    Step 2: I need to place the name of the new sheets in cell C4 of each sheet so I can do a lookup using C4 as my lookup_value, so this can't be a formula like "=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)" because lookup doesn't function properly.

    Step 3: Delete "Template", so that the only things left are the "Summary" sheet and the new sheets.

    Each department will have their own workbook with a "summary" sheet and different sheet names although they will all start off with the same data dump and will all be in the same format. Each department could also have a different number of new sheets added depending on information from the data dump.

    I found a utility (ASAP Utilities) which will do the steps I need done, but it won't record in the macro.

    Help please Budget time is fast approching and each department needs their worksheets.

    Thanks so much for your help
    Last edited by rdunaway; 02-04-2014 at 06:58 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: I need a macro which will add sheets using a template and name them from a column of c

    Hi rdunaway, and welcome to the forums
    It is always an excelletn idea to add a sample workbook showign as clearly as possible your input and your expected results, doesnt have to be huge but should clearly show what you are expecting "success" to look like.

    I am sure you will get lots of responses to your issue from some of the experts here. I do have a working solution to what seems like exactly what you are trying to do but it isnt where I can get to it right now. When I get back to my desktop I will check the thread and respond if you dont already have a solution.

    Adding a sample is done from the "GO Advance" link at the bottom right corner of the posting window

    cheers

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  3. #3
    Registered User
    Join Date
    02-04-2014
    Location
    Big Spring, Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: I need a macro which will add sheets using a template and name them from a column of c

    Hi jmac1947,
    I'm not only new to macros but new to forums as well. Your advice is very much appreciated. I have attached an excel spreadsheet as an example of what I need. I have included some explanations within the sheets. I hope it is helpful. Thanks again for any assistance.

    rdunaway
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: I need a macro which will add sheets using a template and name them from a column of c

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-04-2014
    Location
    Big Spring, Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: I need a macro which will add sheets using a template and name them from a column of c

    Hi John H. Davis,

    Thank you for your contribution. Unfortunately the macro copies the Header formats of "Budget Summary" to "Template" sheet and changes the heading on "Template", then creates the first "new" sheet, naming it Template (2) and errors out on line "ActiveSheet.Name = y" with the following:

    Run-time error '1004':

    Cannot rename a sheet to the same name as another sheet, a referenced object library or a workbook referenced by Visual Basic.

    I found this code from the internet and modified it to fit my data. It works great for creating the sheets:

    Sub rdunaway()

    Dim ws1 As Worksheet
    Set ws1 = ThisWorkbook.Worksheets("Template")

    Dim MyCell As Range, MyRange As Range

    Set MyRange = Sheets("Invoice Summary").Range("A8")
    Set MyRange = Range(MyRange, MyRange.End(xlDown))

    For Each MyCell In MyRange
    ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
    ThisWorkbook.Worksheets("Template(2)").Name = MyCell.Value
    Next MyCell

    End Sub



    All I need now is to put the sheet name into cell C4 of each new sheet (to satisy the lookup_value needed for cell B5) Any Ideas???

    Thanks John H. Davis for your contribution, but not exactly what I'm looking for.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: I need a macro which will add sheets using a template and name them from a column of c

    The error is caused by your data in your sample. In Column A of Sheet "Budget Summary" at the Bottom you have "Template". I had to remove it to get it too work. I think you put it there to show a sample.

  7. #7
    Registered User
    Join Date
    02-04-2014
    Location
    Big Spring, Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: I need a macro which will add sheets using a template and name them from a column of c

    Hi John H. Davis

    Opps, Sorry about that you are correct and the macro does work YEAH!!!! Thank you so much. It still copies formats from "Budget Summary" and pastes them to "Template" , but i commented out these 3 lines and it works perfect.

    ws1.Range("A1:K1").Copy ws.Range("A1")
    ws1.Range("B4").Copy ws.Range("B3")
    ws1.Range("B5").Copy ws.Range("B4")

    Thanks so much!!

  8. #8
    Registered User
    Join Date
    02-04-2014
    Location
    Big Spring, Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: I need a macro which will add sheets using a template and name them from a column of c

    Hi John H. Davis

    Opps, Sorry about that you are correct and the macro does work YEAH!!!! Thank you so much. It still copies formats from "Budget Summary" and pastes them to "Template" , but i commented out these 3 lines and it works perfect.

    ws1.Range("A1:K1").Copy ws.Range("A1")
    ws1.Range("B4").Copy ws.Range("B3")
    ws1.Range("B5").Copy ws.Range("B4")

    Thanks so much!!

  9. #9
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: I need a macro which will add sheets using a template and name them from a column of c

    rdunaway jmac.xlsm

    Hi rdunway,

    Here is an example of how you might do it

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: I need a macro which will add sheets using a template and name them from a column of c

    You're welcome. Glad to help out and thanks for the feedback.

+ 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. Macro to copy and paste values from diff sheets into a template worbook
    By bloom1439 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2013, 10:25 AM
  2. Replies: 5
    Last Post: 06-08-2013, 06:20 AM
  3. Creating a macro to reformat multiple sheets into a new template
    By Etachias in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2013, 12:38 AM
  4. [SOLVED] Filling cells into template based on selection with data in seperate sheets
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2013, 06:54 PM
  5. Macro to create new sheets based on template no longer working
    By pauldaddyadams in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2012, 03:51 PM

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