简体   繁体   中英

Fill a cell range based on start and end date (which will change)

My start and end dates will continually change. I need the appropriate cells to highlight the appropriate range between the start and end dates. Each column will have a date heading. The dates will be a month and year and run for a year. For example, Jan 15, Feb 15, Mar 15......Jan 16. How should I write this formula?

Thanks for your help in advance.

If my image does not post, the excel sheet will look like:

|Supervisors|Job Number|Start date|End Date|Jan-15|Feb-15|Mar-15...
| John Doe  |12345-67  | Jan 15   |June 15 |xxxxx |xxxxx |xxxxx 

Just to clarify the question, you want to put in one heading for each month between the start and end date?

You can use the MONTH() function to extract the month from a date. So using VBA, you could do something like

for index = 0 to (month(enddate) - month(startdate)) 'Insert a header next index

You can do the same with year if they are not all in the same year.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM