Question

I'm currently using Office 2003 to create a rolling forecast. I have a starting point and end point for a time interval (yr/month to yr/month) that I need to populate automatically at certain intervals (I just need a macro that I can assign to a button or something of that sort). I do not know how to code vB, and I'm having trouble trying to formulate a way I could record something along these lines. So, I could use some help.

To start, I need the interval 201308-201412

Every month I would need to drop the past month (eg next month the interval would become 201309-201412)

Once the start of the interval became 201404, the end of the interval would jump to 201512.

This process continues on, where the past month is dropped from the beginning of the interval.

Once 201504 becomes the beginning of the interval, 201612 becomes the end of the interval (what had been 201512 before the past month was dropped).

Also, because lines will be getting deleted/added depending on the month, is there any way to make lines get inserted again to avoid overlapping data? (I am also using TM1, and I have DBRW formulas that will be traveling with these dates- if you're familiar with citrix/tm1)

Let me know if I can explain anything else.

Thank you!

Was it helpful?

Solution

I don't think you need a macro here. Some nested built-in function will do.

Formula for starting interval:

=TEXT(DATE(YEAR(TODAY()),MONTH(TODAY())+1,1),"yyyymm")

This basically returns a date formatted as "yyyymm" of the next month from today

Formula for ending interval:

=IF(MONTH(TODAY())>4,TEXT(DATE(YEAR(TODAY())+1,12,1),"yyyymm"),TEXT(DATE(YEAR(TODAY()),12,1),"yyyymm"))

This checks if today's month is greater than 4, if so move end interval to next year's december otherwise keep it as this year's december.

There are several formulas used here:

TEXT(value,format) - this returns a formatted text
DATE(YEAR,MONTH,DAY) - this returns a date
YEAR(date_serial) - this returns the year from a date serial
MONTH(date_serial) - this returns the month from a date serial
DAY(date_serial) - this returns the day from a date serial
IF(logic,true,false) - if statement in Excel
TODAY() - this returns today's date serial
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top