return first value in column containing search term

brewben

Board Regular
Joined
Nov 5, 2015
Messages
58
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have two tabs in my workbook - first one is Spare Laptops, and the second is UK towns.

In the Office (A) column, I'd like to input a town, and the region/column that town is found in on the 'uk towns' tab, ie B1, C1, D1, E1, F1, G1 is then the result.

Simply put - enter, eg. 'Elgin' in Office, and 'Scotland' will be in Region, etc.

It took me a while, but I've managed to get it to at least check every column to see if the town is listed, but it simply returns the town as the region, not the actual region.

I've used this formula to get this far:

=IFERROR(INDEX('UK Towns'!B:B,MATCH(A2,'UK Towns'!B:B,)),IFERROR(INDEX('UK Towns'!C:C,MATCH(A2,'UK Towns'!C:C,0)),IFERROR(INDEX('UK Towns'!D:D,MATCH(A2,'UK Towns'!D:D,0)),IFERROR(INDEX('UK Towns'!E:E,MATCH(A2,'UK Towns'!E:E,0)),IFERROR(INDEX('UK Towns'!F:F,MATCH(A2,'UK Towns'!F:F,0)),IFERROR(INDEX('UK Towns'!G:G,MATCH(A2,'UK Towns'!G:G,0)),"Town not listed, please check again"))))))

Hope this makes sense.

Thanks in advance.

Bruce






1677171069948.png
1677171122796.png
 
That sounds as though some of the towns have leading/trailing spaces, or other hidden characters.
I will investigate - that does make sense. I will now learn how to use the AGGREGATE function, it seems very powerful.
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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