Meet the Other Phone. A phone that grows with your child.

Meet the Other Phone.
A phone that grows with your child.

Buy now

Please or to access all these features

Chat

Join the discussion and chat with other Mumsnetters about everyday life, relationships and parenting.

Excel / Google sheet formula. Help me before I lose it completely!

32 replies

JoanThursday · 03/02/2022 15:46

Formula aces, I need your help!

I have a spreadsheet with a bunch of names in a particular column (lets call it A1). Some cells in this column have just one name (eg Brown, Bert (Mr)), where as others have several names (eg Green, Sam (Mrs), White, Ned (Mr), Black, Mary (Prof)). Layout of names in the cells is as shown in my examples.

I need to search the data in column A1 and find all the surnames that match the ones I have on a separate list. I'd like the formula to find instances of the names and put 'true' in a second column. If it find two names on the list in one particular cell, it needs only return 'true' once.

I tried to use =IF(OR(A1="Brown",A1="Green",A1="White"),"TRUE","FALSE") but it returned 'FALSE' each time, and it's obviously not correct. I can see the names are there!

I've also tried 'if ... then' and 'find' formulas but I'm getting myself in a right knot with the syntax.

Can anyone help before I throw the whole lot out the window?!

OP posts:
Kfjsjdbd · 03/02/2022 15:48

Could you do it as a v look up?

LeroyJenkinssss · 03/02/2022 15:49

The problem is that your current formula will only find an exact match for the cell. I think you need something like this

JoanThursday · 03/02/2022 15:51

@LeroyJenkinssss - yep, I figured that was the problem. I need to find part of a string rather than than the contents of the entire cell.

I'll have a go with the info you found.

@Kfjsjdbd - I tried that too, but obviously my syntax was totally off!

OP posts:

Interested in this thread?

Then you might like threads about this subject:

toppkatz · 03/02/2022 15:52

Can you not just sort the entire database into alphabetical order?

JoanThursday · 03/02/2022 15:54

Ah, back to the same problem. How do I write the formula so that it searches each cell for multiple names and then returns'TRUE' or 'FALSE'? That's where I'm tripping up. It tells me that I have a parsing problem but not where ...

OP posts:
MindyStClaire · 03/02/2022 15:57

Hmm, a tricky one. A quick google suggests ISTEXT might work?

JoanThursday · 03/02/2022 15:58

@toppkatz

Can you not just sort the entire database into alphabetical order?
No, that won't work unfortunately, because there can be multiple names in each cell with each separated by a comma.

The data has come from another source which can't be sorted alphabetically before I export it into Excel.

I originally split each name out into a cell on its own, but it's making the pivot table I want to run very complicated if I do that.

OP posts:
HacerSonarSusPasos · 03/02/2022 15:59

How about if you use the text to column option on your A1 column, choosing the comma as a separator? Then you have each word in A1 in a separate column and you can use an IF or a Vlookup on each of the resulting columns to find your matches

HacerSonarSusPasos · 03/02/2022 16:01

Please disregard my previous post, THIS is what you need Grin

www.excel-easy.com/examples/contains-specific-text.html

JoanThursday · 03/02/2022 16:02

@MindyStClaire

Hmm, a tricky one. A quick google suggests ISTEXT might work?
@MindyStClaire, yes I found that on Google too.

This is what I'm trying to say:

Find Brown OR White OR Red OR Black in column A1. If you find any of these words, put 'TRUE' in column A2.

So, I'm not matching the full contents of a cell, but a short string within that cell, if that makes sense! This is where I'm tripping up.

OP posts:
HopefulProcrastinator · 03/02/2022 16:04

I'd try using one of the COUNT arguments - probably COUNTIF but haven't crunched data in Excel for a while so little out of practice.

HopefulProcrastinator · 03/02/2022 16:05

Ah, sorry COUNT will literally give numbers instead of True/False arguments. Missed that necessary bit.

JoanThursday · 03/02/2022 16:05

@HacerSonarSusPasos - that looks promising.

It's just how I write it so that it checks each cell against a list of multiple names, and not just one. Still scratching my head on that one!

OP posts:
IsolaPribby · 03/02/2022 16:09

Not exactly the same, but if you apply a filter to the sheet, and then on the column you are working on, go to search and type in the name you are looking for. It will then bring up all the cells which contain that name anywhere in the cell.

JoanThursday · 03/02/2022 16:12

Ha! I might indeed go down that route, @IsolaPribby. Could have bluddy done it by now.

I still need to get 'TRUE' into a new column, because I need to pull the information into a pivot table.

OP posts:
LefttoherownDevizes · 03/02/2022 16:16

I would text to column to get all the surnames in their own cells and then you can do if or multiple times

I don't think you can do if like sadly which is what you need

LeroyJenkinssss · 03/02/2022 16:17

You could do a nested if statement so if search for first name = true, return true, if false search for next name etc etc

IsolaPribby · 03/02/2022 16:18

@JoanThursday just make several more columns and put a true in there every time you get the results from your search. So you will have a column for True for black, another for true for brown etc. Then you can combine those results into one column which says true where any of the others are. Does that make sense?

LefttoherownDevizes · 03/02/2022 16:18

Or just copy the names values into another column (on another tab), remove duplicates and then write true against the rows that have the data you are looking for. Then vlookuo the true values back into your first sheet. It is clunky though

LefttoherownDevizes · 03/02/2022 16:20

Actually www.ablebits.com/office-addins-blog/2017/10/18/excel-if-cell-contains-formulas/ might do it.

JoanThursday · 03/02/2022 16:20

Thanks for all your help. I'm sure it must be possible, but the formula is just seems too complicated for the time / patience I've got.

So, back to the 'text to column' approach for each of the names. Some cells have 6 names and some have only one, so it will complicate the table AND the pivot.

But ... gah. Like I say, I'm losing patience!

OP posts:
LefttoherownDevizes · 03/02/2022 16:21

You should be able to nest using the above too to do once per string

LefttoherownDevizes · 03/02/2022 16:23

The section called

If cell contains one of many text strings (OR logic) will do it

JoanThursday · 03/02/2022 16:23

Yes, I found that page @LefttoherownDevizes. I've bookmarked it because it's so useful!

Buuuuut .... I have 15 names to check against each cell. It's going to be a bloody complicated nested statement.

@IsolaPribby - exactly what I'm going to do!

OP posts:
JoanThursday · 03/02/2022 16:24

And thank you all Flowers

I knew there would be tons of ideas!

OP posts:
Swipe left for the next trending thread