e.g.
12-Jun to 27-Jun <- range of dates
Print/Display all dates in different cells -> 12 Jun 13 Jun 14 Jun 15 Jun 16 Jun ...... 26 Jun 27 Jun
e.g.
12-Jun to 27-Jun <- range of dates
Print/Display all dates in different cells -> 12 Jun 13 Jun 14 Jun 15 Jun 16 Jun ...... 26 Jun 27 Jun
Check this out.![]()
Sub Calc_Date() Dim NextDate As Date 'Set Up Do Loop Range("A1").Value = "Date" Range("A2").Value = "6/21/2013" NextDate = "6/21/2013" Do Until NextDate = "6/27/2013" NextDate = NextDate + 1 'Find the next empty cell in Column F Range("A1").End(xlDown).Offset(1, 0).Value = NextDate Column("A:A").Select Selection.NumberFormat = "m/d/yyyy" Loop End Sub
Thanks,
Gregg
Suppose if your starting date is in Cell A1 and end date is in Cell B1. The following code will display all the dates in the range in column C.
I hope it helps.![]()
Sub showdaterange() Dim rngdiff As Integer Dim strdate As Date strdate = Cells(1, 1) rngdiff = Cells(1, 2) - Cells(1, 1) For i = 1 To rngdiff + 1 Cells(i, 3) = strdate strdate = strdate + 1 Next i Sheets("sheet1").Range("C:C").NumberFormat = "dd-mmm" End Sub
See attached file. Put start and end dates in B1 and B2.
Hope this helps.
Pete
EDIT before submitting:
Ah, it seems that I can't attach a file. Use B1 and B2 for the start and end dates, and put this formula in C1:
=IF(OR(B1="",B2=""),"",B1)
Then put this formula in C2:
=IF(C1="","",IF(C1+1>$B$2,"",C1+1))
and copy down as far as you need to.
Hope this helps.
Pete
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks