On 2002-04-09 08:01, Derek wrote:
Aladin
What if your data in column A is text rather than numbers, this is giving me an error return when I try it
regards
Derek
The target system of formulas applies to the text case too. It requires modification (indicated in bold below) at those places where the data type of A is exploited.
Consider
{"Field1","Field2";
"xza","cat";
"sad","dog";
"xza","cow";
"sad","fox";
"ret","rat";
"sad","mouse"}
in A1:B7.
In D1 enter:
=MATCH(REPT("z",20),Sheet1!A:A)-ROW(1:1)
In D2 enter: sad [ a lookup value ]
In E2 enter:
=IF(
LEN($D$2),VLOOKUP($D$2,OFFSET($A$2,0,0,$D$1,2),2,0),"")
In E3 enter and copy down:
=IF(AND(
LEN($D$2),COUNTIF(OFFSET($A$2,0,0,$D$1,1),$D$2)>COUNTA($E$2:E2)),INDEX(OFFSET($B$2,MATCH(E2,OFFSET($B$2,0,0,$D$1,1),0),0,$D$1,1),MATCH($D$2,OFFSET($A$2,MATCH(E2,OFFSET($B$2,0,0,$D$1,1),0),0,$D$1,1),0)),"")
Here is what you get in the results area:
{6,"";
"sad","dog";
"","fox";
"","mouse"}
Aladin