+ Reply to Thread
Results 1 to 19 of 19

Macro to create new worksheet

  1. #1
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Macro to create new worksheet

    I have a workbook and on the first sheet is a button that I would like to attach to a macro. I would like the macro to create a new worksheet and copy data from another sheet inside the same book. This "template" sheet is hidden so nobody messes with it. I just need the contents of that sheet to copy to that new sheet that gets created from clicking the button (macro). I know I have worked workbooks that have done this and much more. I would love to know how to create a form that would populate the new sheet rather than copying data from an exisiting sheet - but this will work and should be easier and quicker to implement.

    Thanks

    Matt

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

    Re: Macro to create new worksheet

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    I'm sorry but I am not a VB guy. There are portions of the macro that I'm supposed to change with my information from my spreadsheet - could you please point out which? I copy and pasted what you have into my "Macro1" and ran it from MSVBA and it failed.

  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: Macro to create new worksheet

    Can you attach a copy of your worksheet for further review. To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button. The macro does not change any information on your spreadsheet. It only adds a sheet and copies the data in your Template sheet to the new sheet, which is what I thought you wanted to accomplish.

  5. #5
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Red face Re: Macro to create new worksheet

    I have attached the spreadsheet. Sorry for the delay.

    Matt

  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: Macro to create new worksheet

    Which Sheet is your template sheet? And what is your naming convention?

  7. #7
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    the template is Sheet 4

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

    Re: Macro to create new worksheet

    I may be wrong, but I'm guessing Sheet4.

    Maybe:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    Error message. Please see the attached screenshot. thanks
    Attached Images Attached Images

  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: Macro to create new worksheet

    Your code needs to be the same as the post. You are missing a return after the x and after the word True.

  11. #11
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    You are a genius!!! Thank you!!!

  12. #12
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    Can I ask one more questions since you got the workbook? On the Totals sheet you see i have a column of "Ticket Numbers" I defined Names in other sheets where the Ticket Numbers were entered. Do but each time I run my new macro it creates a new sheet and my Ticket numbers and Total Hours columns are no longer correct. Any ideas?

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

    Re: Macro to create new worksheet

    I don't know why? When I test it does not affect the Totals sheet at all. The Totals sheet has formulas which reference, the other sheets, not the new sheet. Do you have another macro you are running afterwards, maybe?

  14. #14
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    This is the only macro. I do have a formulas as you saw. Just simple ones with SUM. I was using the Define Name and then the simple =DefinedName. Is there a way for the macro that creates the new sheet to open a dialog box and ask for the name - then enter that name as the sheet name, enter the name into the next available cell within a range of cells?

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

    Re: Macro to create new worksheet

    Are you trying to sum c19 from the new sheet on the Totals Sheet? What does the formula CSN_8 mean? The current macro already asks for a name to be given the new sheet. Still a bit confused.

  16. #16
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    I am trying to sum E19 to the Totals sheet. But then next to the name of the correct sheet. =CSN_8 is just a link to a Defined Name. If you start typing =C in the formulas bar it will show all of the Names I have Defined. Yes your right it does ask for the name. I should be more specific I guess.

    In addition to what the macro does now - have the macro place the 'Enter Name' into the next available cell within a range of cells as show on the Totals sheet?

    Thanks

    Matt

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

    Re: Macro to create new worksheet

    Maybe:

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    So close! It worked with the workbook you are using but I cleared out all of the sheets except Totals, Template and the hidden sheet. When I enter a name for the defined name it gives me an error that refers to this line in the macro - ActiveWorkbook.Names.Add Name:=y, RefersToR1C1:="=R10C1".

    I'm quite sure you see what I'm trying to do - create a template for mulitple users to use - to track time by sheet for each month. And then have a simple "Totals" page.

    Atttached is my new TEMPLATE file that users will make a copy of each month. Can you take a look when you haev a minute?

  19. #19
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    Thanks for your time on this by the way. It is very nice of you. I just hope I can pay something forward.
    Attached Files Attached Files

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

    Re: Macro to create new worksheet

    It works for me on your new attachment. I didn't receive an error. Remember there are two pop-ups. 1) asks for the new sheet name, 2) asks for the named range name.

  21. #21
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    Ok - it has to do with the Defined Name. Try and do it again but use the following for both sheet name and range name. INC123456

  22. #22
    Registered User
    Join Date
    11-11-2013
    Location
    982
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro to create new worksheet

    Ok - it has to do with the Defined Name. Try and do it again but use the following for both sheet name and range name. INC123456

+ 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 create new worksheet from the current worksheet, with additional changes
    By sards08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-13-2013, 04:13 PM
  2. How to create a macro which will fill a 'table' worksheet from another 'form' worksheet
    By tomgnihtemos in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-18-2013, 01:13 AM
  3. Can you create a macro that creates a macro and saves to a worksheet?
    By rob.parson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2012, 07:49 PM
  4. Macro to create new worksheet with values from existing worksheet
    By SamBam in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2011, 05:33 AM
  5. Macro to create new worksheet
    By ChrisMattock in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2007, 05:18 AM

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