View Single Post
  #6   Report Post  
Dave O
 
Posts: n/a
Default

I solved this using an array function, which allows you to nest
multiple conditions in a formula. Using your example, I created a list
starting in cell A1:
floor
roof
wall
floor
roof
wall
etc, down through cell A18.

Column B1:B18 I populated with dates, starting with 5/1/2004 and adding
3 days to each date so cell B2 = 5/4/2004 and cell B18 = 6/21/2004.

In cells D1:D3 I recreated the entries in column A such that each entry
is represented just once: D1 = floor; D2 = roof; D3 = wall.

In cell E1 I entered this formula:
=SUM(IF(D1=$A$1:$A$18,IF($B$1:$B$18=DATEVALUE("5/1/2004"),IF($B$1:$B$18<=DATEVALUE("6/1/2004"),1,0))))

Ordinarily you invoke a formula by pressing the [Enter] key. To invoke
the array function in cell E1, simultaneously press the [Ctrl] [Shift]
[Enter] keys.

This creates a multi-conditional "lookup": the English translation is
"Find the value in cell D1 (floor) in the range A1:A18, and if the date
in the corresponding row in column B is between May 1st and June 1st,
add 1."

If you prefer not to use the DATEVALUE() function to convert a text
string to a date, you can use a cell reference in the formula. Suppose
cells G1 and G2 contain the dates (formatted and entered as dates): the
formula is
=SUM(IF(D1=$A$1:$A$18,IF($B$1:$B$18=G1,IF($B$1:$B $18<=G2,1,0))))
Again, invoke the array function by simultaneously pressing the [Ctrl]
[Shift] [Enter] keys.

Hope this does it for you!
Dave O