Copied worksheets not referring to previous sheet

joikd

New Member
Joined
Aug 23, 2004
Messages
6
Using the following I've been able to generate copied sheets of "Thursday, 07-02-09" from 7/3/09 through 12/27/09:

Sub Copysheets()
Dim x As Integer
For x = 3 To 365
Worksheets("Thursday, 07-02-09").Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Format(DateSerial(2008, 19, x), "DDDD, MM-DD-YY")
Next x
End Sub

I'm having two issues that I would appreciate any help with:

1. I'm trying to generate copied sheets through 6/30/10, but it errors out after 12/27/09 (although, it went into March once). What am I doing wrong?

2. Each sheet has a beginning balance (C3) that is taken from the previous day's ending balance (='Wednesday, 07-01-09'!N3). But, the generated copies all refer to the original sheet instead of the previous day's. Any ideas on a simple solution?
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Welcome to the Board!

For #1 that's a known error: http://support.microsoft.com/default.aspx?scid=kb;en-us;210684

For #2 this might be a start:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> Copysheets()<br>    <SPAN style="color:#00007F">Dim</SPAN> x <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> LastSheet <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>        <SPAN style="color:#00007F">For</SPAN> x = 3 <SPAN style="color:#00007F">To</SPAN> 365<br>            Worksheets("Thursday, 07-02-09").Copy after:=Worksheets(Worksheets.Count)<br>            <SPAN style="color:#00007F">With</SPAN> ActiveSheet<br>                LastSheet = .Index - 1<br>                .Name = Format(DateSerial(2008, 19, x), "DDDD, MM-DD-YY")<br>                .Range("C3").Formula = "='" & Sheets(LastSheet).Name & "'!N3"<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <SPAN style="color:#00007F">Next</SPAN> x<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

HTH,
 

Watch MrExcel Video

Forum statistics

Threads
1,122,837
Messages
5,598,378
Members
414,234
Latest member
grlevesq

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top