Solved

Copy Worksheet and rename

Posted on 2014-01-02
2
351 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

860 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