View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Searching multiple data to show desired result

In Sheet1,
Place in B2, array-enter, ie confirm the formula via pressing
CTRL+SHIFT+ENTER:
=INDEX(Sheet2!$D$2:$D$100,MATCH(MAX(IF(Sheet2!$C$2 :$C$100=B$1&$A2,Sheet2!$B$2:$B$100)),IF(Sheet2!$C$ 2:$C$100=B$1&$A2,Sheet2!$B$2:$B$100),0))
Copy B2 across/fill down to return the results "as-is" from Sheet2's col D

And if you want to return only the "rightmost" number (ie the number after
the hyphen), then indicatively, using MID, it'll look like this:
=MID(xx,SEARCH("-",xx)+1,99)+0
where xx is the above array formula
and the "+0" is to coerce the text number returned to a real number

Hence, you could try instead in B2, array-entered as befo
=MID(INDEX(Sheet2!$D$2:$D$100,MATCH(MAX(IF(Sheet2! $C$2:$C$100=B$1&$A2,Sheet2!$B$2:$B$100)),IF(Sheet2 !$C$2:$C$100=B$1&$A2,Sheet2!$B$2:$B$100),0)),SEARC H("-",INDEX(Sheet2!$D$2:$D$100,MATCH(MAX(IF(Sheet2!$C$ 2:$C$100=B$1&$A2,Sheet2!$B$2:$B$100)),IF(Sheet2!$C $2:$C$100=B$1&$A2,Sheet2!$B$2:$B$100),0)))+1,99)+0
Copy B2 across/fill down to populate

Success? Celebrate it, hit the YES below
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:27,000 Files:200 Subscribers:70
xdemechanik
---
"lawandgrace" wrote:
Here are the results of my query:

Sheet2:

A B C D
1 CustomerName Date Location No.
2 Customer1 7/6/2009 1A 1 - 8
3 Customer1 7/13/2009 1A 1
4 Customer1 7/15/2009 1A NA
5 Customer1 7/17/2009 1A 1-8

These results are on Sheet2. On Sheet1, I have something that looks like
this (the top row of A thru E and the side row of 1 thru 6 are supposed to
represent the Excel columns/rows):

Sheet1:

A B C D
1 1 2 3
2 A 8
3 B
4 C
5 D

I want the formula in Sheet1, Column B, Row2, to look at the query on Sheet2
for the matching Location (in this case, 1A), the most recent date
(7/17/2009) and show the number in Column D to the furthest right (in this
case it is 1-8 and I only want it to show the 8).

In the original query there are multiple locations (i.e., 1A, 2A, 3A, etc.,
and 1B, 2B, 3B, etc., and so forth).

I hope this is understandable. Thanks for your help.