Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copy Worksheet and rename

Posted on 2014-01-02
2
Medium Priority
?
365 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

916 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