+ Reply to Thread
Results 1 to 7 of 7

Macro to gnereate new sheet which includes the macro to generate a new sheet

  1. #1
    Registered User
    Join Date
    12-27-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2007
    Posts
    15

    Macro to gnereate new sheet which includes the macro to generate a new sheet

    Hello all, this is my first time posting here and I am very much a novice when it comes to VBA and macros. Here is what I am trying to accomplish. My employer has a certain format that they want our weekly timesheet in. So I have already created an Excel workbook that will track my time, calculate the number of hours spent on each project and then I made a macro that generates a time sheet in the format my employer wants to see at the end of each week. All I need help with at this point is the final step which is to make a macro that will copy the existing sheet to a new sheet within the same workbook so I can continue tracking time in the next week on the new sheet without deleting or overwriting the data from the week before. So at the end of the year I will have a workbook with 52 sheets/tabs (for all 52 weeks in the year) which will serve as a permenant log of my time. I would like to have a button I can click in any one of the sheets that will copy the existing sheet and create a new identical sheet, minus all the time entries, but including the botton to creat another sheet. In other words, I want to be able to just click this button at the end of each week and make my new sheet which will include the button to create another new sheet, ect...so it will be self replicating. Is this possible, or is it some sort of circular logic? One thought I had, was I could have one master sheet at the beginning where I store the button that activates the macro to generate a new sheet. I think this would be easier to create, but if possible, I would like to just have the button stored on each weeks timesheet without the need of the master sheet. Also, as an added bonus, if I could get a window to pop up and ask me the "Week Ending" and then use my answer to this question to name the new sheet, that would be really cool.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Macro to gnereate new sheet which includes the macro to generate a new sheet

    Not having a sample to work with, I can only advice you to>

    Have a template sheet so the macro controled by the button will make a new copy of this template button included and the macro will rename it accordingly (from your input)

    try recording your actions into the macro performing the above suggestion

  3. #3
    Registered User
    Join Date
    12-27-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Macro to gnereate new sheet which includes the macro to generate a new sheet

    First of all, thank you rcm for the quick response! So, I tried doing as you suggested and keep getting an error. When I click debug it highlights the line that starts with ActiveSheet.Buttons...(bolded below):

    Sub NewSheet()
    '
    ' NewSheet Macro
    '

    '
    Sheets("TEMPLATE").Select
    ActiveSheet.Buttons.Add(2637.75, 67.5, 120, 98.25).Select
    Sheets("TEMPLATE").Copy Before:=Sheets(2)
    Sheets("TEMPLATE (2)").Select
    Sheets("TEMPLATE (2)").Name = "Time Log DATE HERE"
    End Sub

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Macro to gnereate new sheet which includes the macro to generate a new sheet

    exclude the buttons line

  5. #5
    Registered User
    Join Date
    12-27-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Macro to gnereate new sheet which includes the macro to generate a new sheet

    Thanks, that fixed the problem.

  6. #6
    Registered User
    Join Date
    12-27-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Macro to gnereate new sheet which includes the macro to generate a new sheet

    Do you know how to make it come up with a promt asking for what week ending and then using the answer to name the new tab?

  7. #7
    Registered User
    Join Date
    12-27-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Macro to gnereate new sheet which includes the macro to generate a new sheet

    Found my answer doing a Google search...I used this:

    Sub CopySheet()
    ActiveSheet.Copy Before:=Worksheets(1)
    shtname = InputBox("What's the week ending?", "For Week Ending")
    ActiveSheet.Name = shtname
    End Sub

+ 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. I need a macro that will create a new sheet, generate invoice number
    By Daotor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2013, 09:20 AM
  2. [SOLVED] Macro running on active sheet instead of sheet defined in macro
    By davegscott in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-19-2013, 02:04 PM
  3. [SOLVED] Macro to Copy Data from one Sheet A to Sheet B based on value in cell on sheet A
    By scass in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2012, 07:21 PM
  4. Replies: 1
    Last Post: 07-30-2012, 02:35 PM
  5. Macro to save sheet as .txt also prompt window to generate filename
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2011, 08:18 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