=OFFSET(Sheet2!$D$51,MATCH(Sheet2!$D$2,Sheet2!$C$51:$C$2365,0)+9,0,1,30)
This formula uses OFFSET function in order to define a range to reference..
Syntax of OFFSET(): OFFSET(Reference,rows,columns,[height],[width])
where Reference is the reference cell/range to offset from.
rows is number of rows to offset from reference
columns is number of columns to offset from reference
height is optional is number of rows deep you want to select
width is optional is number of columns wide you want to select.
So we are referencing from cell D51.
To find number of rows, I used MATCH() function, which finds the position within a range that an item is found. I am looking to match what is in D2 (the month) and find the position in range $C$51:$C$2365. Once I find it, I want to go down a further 9 rows in order to get to the row containing the data to chart.
I am staying in column D, so I don't offset by any columns (0) and I want to only get 1 row of data worth by 30 columns wide (Note: I assume you replaced that 30 in those 3 defined ranges to DAY(DATE(Sheet2!IL65494,MONTH((Sheet2!$D$2&" "&Sheet2!$D$3&", "&Sheet2!$D$1)+0)+1,0)) to get the real widths).
=OFFSET(Sheet2!$C$51,MATCH(Sheet2!$D$2,Sheet2!$C$51:$C$2365,0)-1,1,1,DAY(DATE(Sheet2!$D$1,MONTH((Sheet2!$D$2&" "&Sheet2!$D$3&", "&Sheet2!$D$1)+0)+1,0)))
This is a similar formula, but I am offsetting from C51, the number of rows is defined by matching D2 to C51:C2365 and subtracting 1. Then go down 1 row and over 1 column.. Again I want 1 row's worth of data and the width is defined by DAY(DATE(Sheet2!$D$1,MONTH((Sheet2!$D$2&" "&Sheet2!$D$3&", "&Sheet2!$D$1)+0)+1,0)) which gets the Day number using the DAY(Date) function from a date defined by DATE(Year,Month,Day) function, where year is gotten from D1, Month is gotten from creating a date by concatenating D2 with a space, then D3, then a comma, a space and D1 to form something like "April 2, 2009". The +0 converts this to a serial number Excel understands to be the equivalent of that date... then I use the MONTH() function to get the month number from that. I add 1 to go to the next month and the final 0 means day 0, which it will interpret as the day before the 1st (which is the last day of previous month).
I hope this helps you to understand the concepts... As I said, it is sometimes harder to explain than just to come up with the formula.
I have noticed a couple of areas in my own formulas, just by going through this explanation, that could've been improved.. but like I also said, there are many ways to skin a cat!
Good luck.
Bookmarks