Hello MrExcel Gurus,
I have a question that I bet has a simple answer, I just haven't run across it yet. I have code that I created in order to take two dates and list in order ever date in between the two in column A. This is working as expected, but now I need to change the startCell variable to be dynamic. I am doing this because I will be referencing this block of code in a loop and need to continue adding dates to the same column x number of times.
Currently my code is:
startCell will never be any higher in the column than "A4".
Please give me your suggestions. Thanks!
I have a question that I bet has a simple answer, I just haven't run across it yet. I have code that I created in order to take two dates and list in order ever date in between the two in column A. This is working as expected, but now I need to change the startCell variable to be dynamic. I am doing this because I will be referencing this block of code in a loop and need to continue adding dates to the same column x number of times.
Currently my code is:
Code:
Option Explicit
Sub ListDate()
Dim startDate As Date 'startnumber
Dim endDate As Date 'endnumber
Dim j As Date 'loop manipulation
Dim i As Date 'loop manipulation
Dim startCell As Range 'start cell
startDate = Range("B1")
endDate = Range("B2")
Set startCell = Range("A4")
If startDate >= endDate Then 'exits macro if start is larger than end
Exit Sub
End If
j = 0
For i = startDate To endDate
startCell.Offset(j, 0) = i
j = j + 1
Next i
End Sub
startCell will never be any higher in the column than "A4".
Please give me your suggestions. Thanks!