Automatic date in following sheets

wavemehello

Board Regular
Joined
Jan 24, 2006
Messages
221
Hi there,
I have a week in sheet1. For eg.
01/07/07 in A1, 02/07/07 in B1 ....... 07/07/07 in G1.
Now in sheet2 I want to continue 08/07/07 in A1 ..... 14/07/07 in G1
and so on and so forth in following worksheets.
How can I automatically obtain the dates in corresponding columns in the following worksheets?

Thank you
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
HI
try the following codes
Paste them in the macro window(alt F8)

Code:
For a = 1 To Sheets.Count
For b = 1 To 7
c = (a - 1) * 7 + b - 1
Worksheets(a).Cells(1, b) = Cells(1, 1) + c
Next b
Next a
Enter starting date in Cell A1 of sheet1 and Run the macro. It will fill the rest.
Ravi
 

wavemehello

Board Regular
Joined
Jan 24, 2006
Messages
221
It did give the numbers 1,2,3,4,5,6,7 in sheet1 and 8,9,10,11,12,13,14 in sheet2 and so on so forth but I need 1/07/07, 02/07/07 as dates not as the numbers 1,2,3,4,5,6,7. Is it possible?

Thanks
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
try
Code:
Sub test()
Dim i As Long, ii As Long, n As Long
For i = 1 To Sheets.Count
     For ii = 1 To 7
          Sheets("sheet" & i).Cells(1,ii).Value = DateAdd("d", n, "01/07/07")
          n = n + 1
     Next
Next
End Sub
 

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
HI
I suspect you have not entered the date in cell A1. Numbers 1 to 7 get added to A1 to give successive dates.
RAvi
 

wavemehello

Board Regular
Joined
Jan 24, 2006
Messages
221
yes, I now have entered date in A1 and it works for sheet1, sheet2 and sheet3. But when I copy the sheet3 as sheet 4 it does not automatically change in sheet 4.

May I also mention here that sheet1 sheet2 sheet3 are actually named week1 week2 week 3...... week 27. So every new week I copy the worksheet and enter new values for week28. What I need is the automatic continuation of the date. Any suggestion pls?
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Code:
Sub test()
Dim i As Long, ii As Long, n As Long, myDate As Date
myDate = Sheets("Sheet1").Range("a1").Value
For i = 1 To Sheets.Count
     For ii = 1 To 7
          Sheets("sheet" & i).Cells(1,ii).Value = DateAdd("d", n, myDate)
          n = n + 1
     Next
Next
End Sub
 

wavemehello

Board Regular
Joined
Jan 24, 2006
Messages
221
still the same, when I copy sheet3 to sheet4, the dates remain as of sheet3, it automatically does not change to new dates (15 to 21 of july), does not advance to 22 to 28 of july
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Then use Change event
to sheet1 module
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0,0) <> "A1" Then Exit Sub
If (IsEmpty(Target)) + (Not IsDate(Target.Value)) Then Exit Sub
Application.EnableEvents = False
test
Application.EnableEvents = True
End Sub
 

Forum statistics

Threads
1,181,649
Messages
5,931,217
Members
436,784
Latest member
amuljono

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