If one cell contains X make other cell contain Y

fuzzyfuzzy

New Member
Joined
Feb 5, 2018
Messages
7
Hi,

Been struggling with this for a few days and given up. Hopefully you guys will help.

Basically, I want a column to recognise if another cell in the same row contains x then it will display Y

For instance, if B contains one of the cities, I want E to auto-populate the number for each


A B C D E
1 London 10
2 Manchester 12
3 Birmingham 6
4 Newcastle 11
5 Leeds 2
6 Sheffield 9
7 Norwich 6
8 Cardiff 5


I've tried all sorts and going round in circles, i'm sure it's fairly straight forward for those in the know but i'm totally lost with it now. Any help, very much appreciated.

Cheers
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Formatting of this thread has gone wonky since it was posted!

ABCDE were spaced out so that the city fell under column B and number under column E
 
Upvote 0
Forgot to mention.

The city is just part of the contents of the cell. That's my issue. If it just the city in the cell it's fine but I need the city to be recognised in just part of the address.

A
1
2
3
4
5
6
7
8
 
Upvote 0
Your question is a bit hard to understand, partly due to the formatting issues you're having. To format a section of a sheet, you can use one of the special tools - see the HTML Maker in my signature. It will generate something like this:

BCDEFGHI
1AddressCityNumber
2Downtown Leeds2London10
3London Bridge10Manchester12
4123 Main Street, Newcastle11Birmingham6
5Cardiff Fork5Newcastle11
6221B Baker Street, London10Leeds2
7#N/ASheffield9
8Norwich6
9Cardiff5

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet3

Worksheet Formulas
CellFormula
E2=LOOKUP(2,1/FIND($H$2:$H$9,B2),$I$2:$I$9)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



The best guess I have for your question is if you have an address in column B, you want to pull a matching number from another table for the city. The formula above should do that. If this isn't it, let me know.
 
Upvote 0
Thanks very much for your help Eric.

Your suggestion works, but, it doesn't recognise where the city forms part of the address in the one cell.

So if the cell contains "123 John St, Leeds" it wont find it. If the cell only contains "Leeds" it works.

Is there a way around this?

Thanks in advance!

Cheers
 
Upvote 0
Try...

=LOOKUP(9.99999999999999E+307,SEARCH(Cities,$A2),Numbers)

where Cities is a range housing cities of interest and Numbers the corresponding numbers next to Cities.

A2 is a string like 123 John St, Leeds.
 
Upvote 0
Thanks Aladin,

I cant get that to work

This is how i have interpreted the formula on my particular sheet

=LOOKUP(9.99999999999999E+307,SEARCH(Cities,$H24:H34),Numbers,$J24:J34)


I get an error of "too many arguments for this function". The cities i want it to find are in H24:H34 and the numbers I want it to show if it finds a match are in J24:J34
 
Upvote 0
Thanks Aladin,

I cant get that to work

This is how i have interpreted the formula on my particular sheet

=LOOKUP(9.99999999999999E+307,SEARCH(Cities,$H24:H34),Numbers,$J24:J34)


I get an error of "too many arguments for this function". The cities i want it to find are in H24:H34 and the numbers I want it to show if it finds a match are in J24:J34

H24:H34 contains a list of cities and J24:J34 the corresponding numbers, right? If so:

=LOOKUP(9.99999999999999E+307,SEARCH($H$24:$H$34,$A2),$J$24:$J$34)

where A2 houses a target string like "123 John St, Leeds".
 
Upvote 0
Sorry, one last question.

Can you alter the formula so that any currently un-populated cell with that formula doesn't show "n/a" but is just blank?

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,031
Members
449,205
Latest member
Eggy66

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