JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
I have the following code but it doesn't stop looping until it runs out of columns. Please can someone modify it so it stops at the last date?
Thank you,
Jack
I have the following code but it doesn't stop looping until it runs out of columns. Please can someone modify it so it stops at the last date?
Code:
FirstDay = Day(Range("StartDate"))
LastDay = Day(Range("EndDate"))
FirstMonth = Month(Range("StartDate"))
LastMonth = Month(Range("EndDate"))
FirstYear = Year(Range("StartDate"))
LastYear = Year(Range("EndDate"))
LastDate = DateSerial(LastYear, LastMonth, LastDay)
.Cells(5, 3).Value = Range("StartDate")
k = 4
Do Until .Cells(5, k) >= DateSerial(LastYear, LastMonth, LastDay)
DateStamp = DateSerial(FirstYear, FirstMonth, FirstDay + k - 3)
.Cells(5, k).Value = DateStamp
k = k + 1
Loop
Thank you,
Jack