View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
smartin smartin is offline
external usenet poster
 
Posts: 915
Default Using lookup functions with conditions and constantly changingdat

(-) Ions wrote:
I want to have a sheet in my workbook that looks through another sheet for a
person's name (there will be many instances of each person's name) and checks
a due date assigned to that person (compares it to the current date) and
returns a serial number assigned to that person (which will be a different
serial number for different instances of the same name. This of course
should pull one serial number for one employee if the current day is a
certain number of days away from the due date (for example,7 days). That
being said, when that item is finished and the workbook is opened 8 or 9 days
later, it should pull yet a different serial number that is now the next or
"upcoming" serial based on its due date. See below for an example:

Today 01/09/09

Employee Serial # Due Date
Frank 11 01/04/09
Sam 12 01/08/09
Bill 13 01/09/09
Frank 14 01/11/09
Sam 15 01/12/09
Bill 16 01/15/09
Frank 17 01/18/09
Sam 18 01/20/09
Bill 19 01/23/09


Given that, I want another sheet that looks something like what I've pasted
below:

Frank Sam Bill
Next Serials 14 Due on:01/11 15 Due on:01/12 13 Due on:01/09

Notice that I want it to pull the serial and due date for that serial that
is the next one after the current date. Any that are already past their due
date (assumed to be finished) and any beyond just the next due date should
not show.

I have tried using a combo of "if" functions and "vlookup" etc. Vlookup
wasn't working well because it would search for a name and when it found it,
only the first corresponding entry was returned.

Any ideas on how to accomplish this or will it take macros or something?


Array formulae can take care of this. Array formulae must be committed
with Ctrl+Shift+Enter (not just Enter).

I put your data with headers in A3:Cx, and placed "today's date" value
in C1.

The serial formula for "Frank" is:
=SMALL(IF(($A$4:$A$12="Frank")*($C$4:$C$12$C$1),$ B$4:$B$12),1)

The text-with-due date formula is:
="Due on: " &
TEXT(SMALL(IF(($A$4:$A$20="Frank")*($C$4:$C$20$C$ 1),$C$4:$C$20),1),"mm/dd")

You could substitute cell references in place of hard-coded names to
make these more versatile.