RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 788
- Office Version
- 2010
- Platform
- Windows
Hello, I have a date set as "mindate" which is a long, the serial is 43467 which is 02/01/2019 (2nd Jan)
I'm then turning this into the first day of that month using dateserial
And finally, pasting it in sequence, iterating up one month.
What's happening is that if I include the format section, for some reason it's formatting in a weird way and I'm getting "19/01/21"
When I remove format, it goes in perfectly as 01/01/2019, 01/02/2019 etc all the way up to 01/12/2021 (35 iterations)
I'd like to have those dates display neatly as Jan-19, Feb-19, Mar-19 etc.
Thanks.
I'm then turning this into the first day of that month using dateserial
And finally, pasting it in sequence, iterating up one month.
VBA Code:
RBD.Activate
LastrowRBD = Cells(Rows.Count, "A").End(xlUp).Row
mindat = CLng(Application.WorksheetFunction.Subtotal(5, Range("B2:B" & LastrowRBD)))
mindat = DateSerial(Year(mindat), Month(mindat), 1)
maxdat = DateSerial(Year(Date), 12, 31)
x = DateDiff("m", mindat, maxdat)
Rarise.Activate
Range("C3").Activate
y = 0
Do Until y = x
ActiveCell.Value = Format(DateAdd("m", y, mindat), "mmmm-yy")
y = y + 1
ActiveCell.Offset(0, 1).Activate
Loop
What's happening is that if I include the format section, for some reason it's formatting in a weird way and I'm getting "19/01/21"
When I remove format, it goes in perfectly as 01/01/2019, 01/02/2019 etc all the way up to 01/12/2021 (35 iterations)
I'd like to have those dates display neatly as Jan-19, Feb-19, Mar-19 etc.
Thanks.