Second thread ever - sorry if I make mistakes. I'm new to VBA.
I'm making a macro that finds out the current month & year based off the Now function. I place the month in cell H1, the year in H2, and Month-Year in H3.
I want all 3 of those cells to show the next month, year, month-year for 15 months in the cells to their right. (I plan to enter a formula in cell H4:V4 that uses COUNTIFS and I plan to use the months and years listed in H1:V1, H2:V2 as the criteria) (Also, I plan to use H3:V3 as the x axis of a graph later on...)
I know I can quickly do this in excel without a macro, but I'm making the macro for some colleagues who don't know how to use excel and I want to quickly automate a task that is required monthly.
My attempt: To do this, I used the record macro to select H3 and auto fill until V3 - that worked great for Month-Year...
However, I tried to take the values of H1 and just add 1 and so on through the cells on the right. My problem arises quickly because the next "month" in cell I1 is 13 instead of 1. I don't know how to subtract 12 if the value is greater than 12. And I have no idea how to make the Year in I2 only add 1 when its a new year.
I think I need to do an IF THEN statement but I'm not sure how to tackle that.
As you can see, I have no idea what I'm doing but I've spent a lot of time trying to figure this out.
Thanks!
Bookmarks