Hi guys,
To sum of this up is it possible to display date range in weeks based on a start date and end date inputted in two cells.
I built a code where when a user inputs two dates a start date in one cell (say a1) and end date (say b1) the code will display all the dates between those across a certain set of columns. I want to change this so that instead of displaying all the dates it will display the dates in a week range in columns. So if the user inputs a start date is "12/01/2016" and a end date "12/15/2016" the code will populate a week range across columns. So since the week count is 2 in column C would then have "Dec 1 - Dec 8" and column D is "Dec 11- Dec 15"
here is my code to display the days
To sum of this up is it possible to display date range in weeks based on a start date and end date inputted in two cells.
I built a code where when a user inputs two dates a start date in one cell (say a1) and end date (say b1) the code will display all the dates between those across a certain set of columns. I want to change this so that instead of displaying all the dates it will display the dates in a week range in columns. So if the user inputs a start date is "12/01/2016" and a end date "12/15/2016" the code will populate a week range across columns. So since the week count is 2 in column C would then have "Dec 1 - Dec 8" and column D is "Dec 11- Dec 15"
here is my code to display the days
Code:
Dim datez As Date
Dim datez2 As Date
Dim totaldatez As Integer
Dim totaldatez2 As Integer
Dim nwks As Integer
If Cells(6, "g").Value > "" And Cells(6, "h").Value > "" Then
Application.EnableEvents = False
datez = Cells(6, "g").Value
datez2 = Cells(6, "h").Value
totaldatez2 = DateDiff("d", datez, datez2)
nwks = DateDiff("ww", datez, datez2)
totaldatez = DateDiff("d", datez, datez2) + 1
Dim a As Integer
Dim b As Integer
a = 1
b = 9
For a = 1 To totaldatez
' datez = Format(datez, "mm/dd")
Cells(6, b).Value = datez
Cells(6, b).NumberFormat = "dd-mmm"
Cells(6, b).Orientation = xlUpward
datez = datez + 1
b = b + 1
' Range(Cells(9, a), Cells(10, a)).Interior.ColorIndex = 15
' Range(Cells(9, a), Cells(10, a)).Borders.ColorIndex = vbBlack
If a = totaldatez Then
Exit For
End If
Next a
ElseIf Cells(4, 1).Value = "" Or Cells(4, 2).Value = "" Then
Range("i1:z10").Clear
End If
Application.EnableEvents = True