The code below works to get the actual dates of the start and end date as well as all dates in between. I have formulae in columns B, C and D thus the filldown portion of the code.
What I would like is to copy the MONTHS between two periods instead of dates. The start and end dates would be in the format of Apr-2017, May-2017 etc. So if I chose Apr-2017 as start period and Sep-2017 as end period I would want to see, starting in A2, Apr-2017, May-2017, Jun-2017, Jul-2017, Aug-2017 and Sep-2017. All assistance greatly appreciated.
What I would like is to copy the MONTHS between two periods instead of dates. The start and end dates would be in the format of Apr-2017, May-2017 etc. So if I chose Apr-2017 as start period and Sep-2017 as end period I would want to see, starting in A2, Apr-2017, May-2017, Jun-2017, Jul-2017, Aug-2017 and Sep-2017. All assistance greatly appreciated.
Code:
Sub CopyDates()
Dim OutRng As Range
Dim StartValue As Variant
Dim EndValue As Variant
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lastrow As Long
Set ws1 = Sheets("Scorecard")
Set ws2 = Sheets("Data_1")
StartValue = ws1.Range("K1").Value
EndValue = ws1.Range("K2").Value
ws2.Range("A3:B500").Clear
Set OutRng = ws2.Range("A2")
If EndValue - StartValue <= 0 Then
Exit Sub
End If
ColIndex = 0
For i = StartValue To EndValue
OutRng.Offset(ColIndex, 0) = i
ColIndex = ColIndex + 1
Next
lastrow = ws2.Range("A" & Rows.Count).End(xlUp).Row
ws2.Range("B2:B" & lastrow).FillDown
End Sub