? for Harald Staff on copying 52 worksheets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello and thanks
your macro worked great and I thank you but could you tell me step by step how to interupt this for example Date Serial
D = DateSerial(2004, 1, 1 + (L - 1) * 7)
Worksheets(1).Copy _
After:=Worksheets(Worksheets.Count)

What does the (2004,1,1+(L-1)*7) stand for or how do you interupt this?
Also the macro calls for Worksheets (1).copy _
I had to rename my first worksheet from "Master_Timesheet" to "1" for the macro to work.
Could you say in the Macro.....Worksheets ("Master_Timesheet").copy?
Thank you once again
 
This part

+ (L - 1) * 7

calculates the number of days to add to the date Jan 1, 2004, based on adding 7 days for each
increase of 1 in the value of L. Assuming the value of L is initially 1, the result is 0 * 7,
i.e. add no days. When L = 2, (L-1)*7 = 7, so you add 7 days to the date Jan 1, 2004.

You should not have to change the worksheet name. Worksheets(1) specifies the first worksheet,
but its position, not by its name. If Master_TimeSheet isn't the first worksheet, that's the
problem. You could change the code to

Worksheets("Master_TimeSheet".Copy

Then it doesn't have to be the first worksheet. Excel finds it by looking at the sheet names,
not their positions.
 
Back
Top