Lookup From a Column based on Multiple Criteria (in Columns)

Jon760

New Member
Joined
Jun 13, 2013
Messages
15
Hi folks,

Below is a visual of my problem. I have zips all listed in one row / several columns B:F (all zips are unique), I would like to have zip in Column J lookup the value in Column A, if it finds a zip that are in columns B:F. Do you have any suggestion? or maybe how I can simply copy-transpose the zip and replicate the city with the number of instances so that I can do a simple vlookup?

Thank you for whatever help of thoughts you may have.

 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Here's a UDF you can try. Install the function then use it as in the example below. R is the entire data range, excluding the header row.
Excel Workbook
ABCDEFGHIJK
1CityZip
2Seattle980019801798057981689801097011Portland
3Portland970079709997011970579700192008San Diego
4San Diego921019200892084920819191998057Seattle
Sheet6



Code:
Function ZipCity(R As Range, Zip As Long) As String
Dim Fnd As Range
Set Fnd = R.Find(Zip)
If Fnd Is Nothing Then
    ZipCity = ""
Else
    ZipCity = Cells(Fnd.Row, R.Columns(1).Column).Value
End If
End Function
 
Upvote 0
Here's a UDF you can try. Install the function then use it as in the example below. R is the entire data range, excluding the header row.
Sheet6

ABCDEFGHIJK
1CityZip
2Seattle9800198017980579816898010 97011Portland
3Portland9700797099970119705797001 92008San Diego
4San Diego9210192008920849208191919 98057Seattle

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:26px;"><col style="width:19px;"><col style="width:16px;"><col style="width:42px;"><col style="width:68px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
K2=zipcity($A$2:$F$4,J2)

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4


Code:
Function ZipCity(R As Range, Zip As Long) As String
Dim Fnd As Range
Set Fnd = R.Find(Zip)
If Fnd Is Nothing Then
    ZipCity = ""
Else
    ZipCity = Cells(Fnd.Row, R.Columns(1).Column).Value
End If
End Function


Thanks so much, it worked! Cheers to you man.
 
Upvote 0
Can you use something like this? You need to use Cntrl+Shift+Enter. Then copy down. Here is the formula
=INDEX($A$2:$A$4,SMALL(IF($B$2:$F$4=$J2,ROW($A$2:$A$4)-ROW($A$2)+1),1))


<tbody>
</tbody>
CityZip
Seattle980019801798057981689801097011Portland
Portland 970079709997011970579700192008San Diego
San Diego921019200892084920819191998057Seattle

<colgroup><col span="10"><col></colgroup><tbody>
</tbody>
 
Upvote 0
Can you use something like this? You need to use Cntrl+Shift+Enter. Then copy down. Here is the formula
=INDEX($A$2:$A$4,SMALL(IF($B$2:$F$4=$J2,ROW($A$2:$A$4)-ROW($A$2)+1),1))

<tbody>
</tbody>
CityZip
Seattle980019801798057981689801097011Portland
Portland970079709997011970579700192008San Diego
San Diego921019200892084920819191998057Seattle

<tbody>
</tbody>

Fabulous! The INDEX formula worked, thanks Mike. What if I simply copy and paste those cities (Column A) to Column G and do a lookup, what would the formula be?
 
Upvote 0
Well, as I see it, given only the city name (and no number to distinguish the city), how would would the formula know which number to find? For example, the formula will recognize that 97007, 97099, 97011, 97057, and 97001 are tied to Portland.
 
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,677
Members
449,092
Latest member
tayo4dgacorbanget

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