?
Solved

Copy Worksheet and rename

Posted on 2014-01-02
2
Medium Priority
?
364 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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 will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

719 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