Solved

Copy Worksheet and rename

Posted on 2014-01-02
2
343 Views
Last Modified: 2014-01-03
I need to copy my active worksheet and have it duplicate it for each saturday of every week for the entire year of 2014. I need the format of the worksheet to be named: "01-04-14". How can I write a macro to have it duplicate my sheet with 52 sheets with each saturday as the name?
0
Comment
Question by:Lawrence Salvucci
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39753022
Here is a macro that will copy the active worksheet once for every Saturday of the year. It will put these sheets in order after the last tab, and name them as mm-dd-yy.
Sub SaturdaySheetMaker()
Dim wsTemplate As Worksheet
Dim dat As Date, dat2 As Date
Dim celHome As Range
Application.ScreenUpdating = False
Set wsTemplate = ActiveSheet
Set celHome = ActiveCell
dat = DateSerial(Year(Date), 1, 1)
dat2 = dat + 6 - Weekday(dat, vbMonday)
If dat2 < dat Then dat2 = dat2 + 7
Do Until Year(dat2) > Year(dat)
    wsTemplate.Copy after:=ActiveWorkbook.Worksheets(ActiveWorkbook.Worksheets.Count)
    ActiveSheet.Name = Format(dat2, "mm-dd-yy")
    dat2 = dat2 + 7
Loop
Application.Goto celHome
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:Lawrence Salvucci
ID: 39753464
Thank you very much!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now