Help with Lookup

jagsdj

New Member
Joined
May 8, 2002
Messages
7
hello...:)

I have a Excel Worksheet with some columns and one column is the number portion of an address field, another column is the text portion of the address field. For example, column 1 contains '700' and column 2 contains 'Airport dr'. This is what the worksheet looks like:
Street# Address
700 Airport dr

Here comes the spinner...

I have another worksheet which contains the text field of the address portion and it also contains a 'High' field and a 'Low' Field as well as a column which contians the city name.
So, my second worksheet looks like this:
Address High Low City
Airport dr 100 300 Acworth
Airport dr 500 800 Canton
...

My question is how would I set this up so that based on the information in worksheet1 that I am able to select the second airport dr, since the street# 700, falls within the range of the second record. So, the city would be canton and NOT acworth.
Did that make sense?

I tried to use a VLOOKUP, but to no avail..

All help is GREATLY appreciated!
jags
jagsdj@hotmail.com
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
On 2002-05-09 14:47, jagsdj wrote:
hello...:)

I have a Excel Worksheet with some columns and one column is the number portion of an address field, another column is the text portion of the address field. For example, column 1 contains '700' and column 2 contains 'Airport dr'. This is what the worksheet looks like:
Street# Address
700 Airport dr

Here comes the spinner...

I have another worksheet which contains the text field of the address portion and it also contains a 'High' field and a 'Low' Field as well as a column which contians the city name.
So, my second worksheet looks like this:
Address High Low City
Airport dr 100 300 Acworth
Airport dr 500 800 Canton
...

My question is how would I set this up so that based on the information in worksheet1 that I am able to select the second airport dr, since the street# 700, falls within the range of the second record. So, the city would be canton and NOT acworth.
Did that make sense?

I tried to use a VLOOKUP, but to no avail..

All help is GREATLY appreciated!
jags
jagsdj@hotmail.com

Use
=INDEX(A1:D3,MATCH(700,C1:C3)+1,1)
 
Upvote 0
I'll assume that A1:B2 in Sheet1 has the following:

{"Street#","Address";
700,"Airport dr"}

and that A1:D3 in Sheet2:

{"Address","High","Low","City";
"Airport dr",100,300,"Acworth";
"Airport dr",500,800,"Canton"}

In C1 in Sheet1 enter: City

In C2 enter:

=IF(COUNTIF(Sheet2!A:A,B2),INDEX(Sheet2!D:D,SUMPRODUCT((B2=Sheet2!A2:A3)*(A2>=Sheet2!B2:B3)*(A2<=Sheet2!C2:C3)*(ROW(Sheet2!D2:D3)))),"Not found")

Note. This formula assumes that for a combination of street# and address in Sheet1, there exist either no corrresponding city value or just a single city value in Sheet2. Although checking for the latter condition possible, it would be expensive to do so.

Aladin
 
Upvote 0
aladin,

I tried your formulae and it keeps giving me "not found" for all cells. I noticed that ALL references point to Sheet2, shouldn't at least one of the references point to sheet1?

I've tried many variations of the formulae and nothing seems to work. I would REALLY appreciate your help...thanks again.

here is some sample data again:
this is sheet1, SNO = street number
SNO Street City
2097 SUGAR PIKE RD *woodstock*
5450 SUGAR PIKE RD *canton*

sheet2:
Address High Low City
SUGAR PIKE RD 2350 2001 WOODSTOCK
SUGAR PIKE RD 5935 2351 CANTON

the astericks represent what SHOULD be poupulated from sheet2...

thanks again!!
all help is greatly appreciated
 
Upvote 0
On 2002-05-20 12:28, jagsdj wrote:
aladin,

I tried your formulae and it keeps giving me "not found" for all cells. I noticed that ALL references point to Sheet2, shouldn't at least one of the references point to sheet1?

I've tried many variations of the formulae and nothing seems to work. I would REALLY appreciate your help...thanks again.

here is some sample data again:
this is sheet1, SNO = street number
SNO Street City
2097 SUGAR PIKE RD *woodstock*
5450 SUGAR PIKE RD *canton*

sheet2:
Address High Low City
SUGAR PIKE RD 2350 2001 WOODSTOCK
SUGAR PIKE RD 5935 2351 CANTON

the astericks represent what SHOULD be poupulated from sheet2...

thanks again!!
all help is greatly appreciated

Here is Sheet2 where your data is:

<CENTER><TABLE ALIGN=CENTER BORDER=1 BORDERCOLOR=#C0C0C0 CELLSPACING=0><TR><TD COLSPAN=5 BGCOLOR=#0C266B ><TABLE ALIGN=CENTER BORDER=0 WIDTH=100%><TR><TD ALIGN=LEFT><FONT COLOR=WHITE>Microsoft Excel - aaRetVal jagsdj.xls</FONT></TD><TD ALIGN=RIGHT><FONT COLOR=WHITE SIZE=2>___Running: xl2000 : OS = Windows (32-bit) NT 5.00</FONT></TD></TR></TABLE></TD></TR><TR><TD BGCOLOR=#D4D0C8 COLSPAN=5>(<U>F</U>)ile (<U>E</U>)dit (<U>V</U>)iew (<U>I</U>)nsert (<U>O</U>)ptions (<U>T</U>)ools (<U>D</U>)ata (<U>W</U>)indow (<U>H</U>)elp</TD></TR><TR><TD BGCOLOR=WHITE COLSPAN=5><TABLE BORDER=0><TR><TD COLSPAN=5% ALIGN=CENTER BGCOLOR=White>A1</TD><TD COLSPAN=10% ALIGN=RIGHT BGCOLOR=#D4D0C8 >=</TD><TD COLSPAN=85% ALIGN=LEFT BGCOLOR=White>Address</TD></TR></TABLE></TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER>
</TD><TD BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>A</CENTER></TD><TD BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>B</CENTER></TD><TD BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>C</CENTER></TD><TD BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>D</CENTER></TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>1</CENTER></TD><TD BGCOLOR=#969696 ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>Address</FONT></TD><TD BGCOLOR=#969696 ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>High</FONT></TD><TD BGCOLOR=#969696 ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>Low</FONT></TD><TD BGCOLOR=#969696 ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>City</FONT></TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>2</CENTER></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>SUGAR PIKE RD</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Right VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>2350</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Right VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>2001</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>WOODSTOCK</FONT></TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>3</CENTER></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>SUGAR PIKE RD</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Right VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>5935</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Right VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>2351</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>CANTON</FONT></TD></TR><TR><TD COLSPAN=5><U>Sheet2</U></TD></TR></TABLE>
<FONT COLOR=#339966>To see the formula in the cells just click on the cells hyperlink</FONT>

<FONT COLOR=#339966 SIZE=1>The above image was automatically generated by [HtmlMaker V1.26]</FONT>
<FONT COLOR=#339966 SIZE=1>If you want FREE SOFT, <A HREF=mailto:corosuke@chan.co.jp>click here</A> and Colo will email the file to you</FONT>
<FONT COLOR=#339966 SIZE=1>This code was graciously allowed to be modified: by <A HREF=mailto:ivanmoala@xtra.co.nz>Ivan F Moala</A> All credit to Colo</FONT>
</CENTER>

Here is Sheet1 where you want to retrieve the city value for a given SNO and Street:

<CENTER><TABLE ALIGN=CENTER BORDER=1 BORDERCOLOR=#C0C0C0 CELLSPACING=0><TR><TD COLSPAN=5 BGCOLOR=#0C266B ><TABLE ALIGN=CENTER BORDER=0 WIDTH=100%><TR><TD ALIGN=LEFT><FONT COLOR=WHITE>Microsoft Excel - aaRetVal jagsdj.xls</FONT></TD><TD ALIGN=RIGHT><FONT COLOR=WHITE SIZE=2>___Running: xl2000 : OS = Windows (32-bit) NT 5.00</FONT></TD></TR></TABLE></TD></TR><TR><TD BGCOLOR=#D4D0C8 COLSPAN=5>(<U>F</U>)ile (<U>E</U>)dit (<U>V</U>)iew (<U>I</U>)nsert (<U>O</U>)ptions (<U>T</U>)ools (<U>D</U>)ata (<U>W</U>)indow (<U>H</U>)elp</TD></TR><TR><TD BGCOLOR=WHITE COLSPAN=5><TABLE BORDER=0><TR><TD COLSPAN=5% ALIGN=CENTER BGCOLOR=White>A1</TD><TD COLSPAN=10% ALIGN=RIGHT BGCOLOR=#D4D0C8 >=</TD><TD COLSPAN=85% ALIGN=LEFT BGCOLOR=White>SNO</TD></TR></TABLE></TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER>
</TD><TD BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>A</CENTER></TD><TD BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>B</CENTER></TD><TD BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>C</CENTER></TD><TD BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>D</CENTER></TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>1</CENTER></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>SNO</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>Street</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>City</FONT></TD><TD BGCOLOR=#FFFFFF>
</TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>2</CENTER></TD><TD BGCOLOR=#FFFFFF ALIGN=Right VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>2097</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>SUGAR PIKE RD</FONT></TD><TD BGCOLOR=#FFCC00 ALIGN=Left VALIGN=BOTTOM ><A HREF=javascript:alert('=IF(COUNTIF(Sheet2!A:A,B2),INDEX(Sheet2!D:D,SUMPRODUCT((B2=Sheet2!$A$2:$A$3)*(A2%3E=Sheet2!$B$2:$B$3)*(A2%3C=Sheet2!$C$2:$C$3)*(ROW(Sheet2!$D$2:$D$3)))),%22Not%20found%22)')><FONT FACE=Arial COLOR=#000000>WOODSTOCK</FONT></A></TD><TD BGCOLOR=#FFFFFF>
</TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>3</CENTER></TD><TD BGCOLOR=#FFFFFF ALIGN=Right VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>5450</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>SUGAR PIKE RD</FONT></TD><TD BGCOLOR=#FFCC00 ALIGN=Left VALIGN=BOTTOM ><A HREF=javascript:alert('=IF(COUNTIF(Sheet2!A:A,B3),INDEX(Sheet2!D:D,SUMPRODUCT((B3=Sheet2!$A$2:$A$3)*(A3%3E=Sheet2!$B$2:$B$3)*(A3%3C=Sheet2!$C$2:$C$3)*(ROW(Sheet2!$D$2:$D$3)))),%22Not%20found%22)')><FONT FACE=Arial COLOR=#000000>CANTON</FONT></A></TD><TD BGCOLOR=#FFFFFF>
</TD></TR><TR><TD WIDTH=1% BGCOLOR=#D4D0C8 ALIGN=CENTER><CENTER>4</CENTER></TD><TD BGCOLOR=#FFFFFF ALIGN=Right VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>2000</FONT></TD><TD BGCOLOR=#FFFFFF ALIGN=Left VALIGN=BOTTOM ><FONT FACE=Arial COLOR=#000000>KING'S RD</FONT></TD><TD BGCOLOR=#FFCC00 ALIGN=Left VALIGN=BOTTOM ><A HREF=javascript:alert('=IF(COUNTIF(Sheet2!A:A,B4),INDEX(Sheet2!D:D,SUMPRODUCT((B4=Sheet2!$A$2:$A$3)*(A4%3E=Sheet2!$B$2:$B$3)*(A4%3C=Sheet2!$C$2:$C$3)*(ROW(Sheet2!$D$2:$D$3)))),%22Not%20found%22)')><FONT FACE=Arial COLOR=#000000>Not found</FONT></A></TD><TD BGCOLOR=#FFFFFF>
</TD></TR><TR><TD COLSPAN=5><U>Sheet1</U></TD></TR></TABLE>
<FONT COLOR=#339966>To see the formula in the cells just click on the cells hyperlink</FONT>

<FONT COLOR=#339966 SIZE=1>The above image was automatically generated by [HtmlMaker V1.26]</FONT>
<FONT COLOR=#339966 SIZE=1>If you want FREE SOFT, <A HREF=mailto:corosuke@chan.co.jp>click here</A> and Colo will email the file to you</FONT>
<FONT COLOR=#339966 SIZE=1>This code was graciously allowed to be modified: by <A HREF=mailto:ivanmoala@xtra.co.nz>Ivan F Moala</A> All credit to Colo</FONT>
</CENTER>

Is this not what you wanted to have?

Aladin
 
Upvote 0
yes...

but, all its giving me is "not found" in every row. I double checked the values against sheet2 and there are matches there, but in the row there are 'not found'.

any ideas!

I really do appreciate your time and patience...

thanks again...

jags
 
Upvote 0
On 2002-05-20 13:03, jagsdj wrote:
yes...

but, all its giving me is "not found" in every row. I double checked the values against sheet2 and there are matches there, but in the row there are 'not found'.

any ideas!

I really do appreciate your time and patience...

thanks again...

jags

Your SNO values are maybe differently formatted in Sheet1 and Sheet2. You can check this by applying:

=ISNUMBER(an-SNO-cell)

Another possibility is that the street mames are different because of extra spaces within an around. You can check for that bu using:

=LEN(a-street-cell) in both sheets.
 
Upvote 0
aladin,

There's just SOMETHING i'm missing...any other ideas!?!? I just can't get it to work, I do have all the datatypes of the appropriate fields correct and they do match.

any other ideas!
Thanks again!!!


jags
 
Upvote 0
the formulae:
IF(COUNTIF(Sheet2!A:A,K2),INDEX(Sheet2!D:D,SUMPRODUCT((K2=Sheet2!$A$2:$A$4062)*(J2>=Sheet2!$B$2:$B$4062)*(J2<=Sheet2!$C$2:$C$4062)*(ROW(Sheet2!$D$2:$D$4062)))),"NOT FOUND")

the 'sumproduct' result is returning a #NUM! error, I don't think that's right...

Again, I really do appreciate your help and patience...

thanks
jags
 
Upvote 0
Aladin,

I wanted to thank you for your help...you helped me alot...the trouble was not with your formulae but with the data types of my fields in excel!

THanks again!
jags
 
Upvote 0

Forum statistics

Threads
1,214,406
Messages
6,119,330
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top