Sheets conditional formatting if contains text from another cell - google-sheets

I have a Google sheet which has a column for business name (A) and a column for city (B). I would like to set conditional formatting such that if the city name is contained within the business name on the same row, the business name will be highlighted.
list example
Every row contains different business/city data, and there are thousands of rows. I need one formula that will work for the whole sheet.
I know how to do it if the city name and business name are exactly the same =$A$2:$A=$B2, but struggling to figure out how to do it if just a portion matches. Putting an asterisk before $B2 broke the formula.

=REGEXMATCH ($A2,$B2) would do the work too!

Use SEARCH:
=AND(ISNUMBER(SEARCH(TRIM(B2),A2)),B2<>"")
with range starting from A2. You search if A2 contains text from B2 and returns starting number if found. So if it is a number then ISNUMBER returns TRUE
Result:

Related

Combining a Cell Reference and Wildcard as Criterion in Google Sheets CountIf Formula

I'm struggling with writing the proper syntax for this formula in Google Sheets. In one sheet called Game Log, in the H column I have data that can be a range of names (1 - 10 names per row). I'm trying to construct a COUNTIF statement that would search for the name in all the rows for that column. There can be several other names in the same column so I need to use the wildcard * to find any occurrence of the name in each row. So for example, the current code below would count all occurrence of Adam in the rows.
=COUNTIF('Game Log'!H3:H102, "*Adam*")
What I would like to do is replace the hard codes "Adam" with a cell reference (in this case B2). Is it possible to combine that cell reference with the wild card? The know the code below doesn't work (as it would return text counting occurrences of B2), but is something like this possible?
=COUNTIF('Game Log'!H3:H102, "*B2*")
Have you tried something like this?
=COUNTIF('Game Log'!H3:H102, "*" & B2 & "*")
That ought to look for any string value, followed by the cell value, followed again by any string value. It's essentially just performing separate checks, in sequence, which allows you to search for different value types (in this case string wildcard + cell value + string wildcard).

Is there any formula to select the column dynamically in the below case?

Refer the worksheet here - https://docs.google.com/spreadsheets/d/1g3mthqijmB7lySfKUvt2NjYT-zVA5oyXr1hJKcJZkdc - Feel fee to edit.
I'm currently trying to get data from a specific column each time the data validation is changed.. It should pull the Names corresponding to FALSE values.. Currently I'm achieving this using multiple IF functions.. If there is a way to directly match the validation input to the row header and then get the values, it would be super great.
See my duplicate sheet ("Erik Help"):
=FILTER(E2:E,FILTER(F2:J,F1:J1=B2)=FALSE)
In plain English, this reads as follows: "Return any names in Column E where the header in in Columns F to J matches the value in cell B2 and where the corresponding value for the name is FALSE."
This formula is written flexibly, assuming that you will have more than two names in Column E within your real sheet. If there are more columns, just extend both instances of J to match the new rightmost column.

Select the last two names in google sheet

In my data sheet1, I want to use the 'Name in use' column (B) with the last two names with ARRAYFORMULA. 
In my data sheet2, I want column (B) to be repeated with the same code next to the column A get filled 
Please find the sample date sheet below  https://docs.google.com/spreadsheets/d/1_AWRjexJNAcgNGsmrBKU_8JYL03UbAGeiyy4oI8B9fU/edit?usp=sharing 
 Regards,
Nimal PereraSri Lanka
Sheet 1
Your formula seems fine, just the ArrayFormula() needs tweaking. As noted in the docs, ArrayFormula() takes in a range, rather than a single cell.
You would have to do something like this:
=ARRAYFORMULA(IFERROR(UPPER(TRIM(RIGHT(SUBSTITUTE(A2:A5," ",REPT(" ",60)),120)))))
Essentially you type in the range you'd like it to apply on. So at any moment, instead of selecting a single cell for that row, you select the range. If you'd want to apply it to the entire column, use A2:A. You even did it right on sheet2
Sheet 2
Your names seem to be importing correctly once Sheet1 is done right. To have the same code everywhere, use something like this:
=ARRAYFORMULA(IF(LEN(A2:A),"SSD",""))

Count the Occurences of a text for the whole spreadsheet

I have a spreadsheet where in every column I have a list of names. They can repeat, and whats even worse - cells can contain some additional text (apart from the name).
What I want to do is count the occurrences of the name in the whole spreadsheet (only looking at the name, omitting the potential additional text). Is Possible?
I tried the formula =UNIQUE, but it does not work vertically (I'm working with Google Sheets)
Example of a document https://docs.google.com/spreadsheets/d/1STtJr0yisSeuv2w8_JVgQABAL5EDzI8aFmH8Vp2cOko/edit?usp=sharing
You can use Countif, Arrayformula, and Regexreplace to accomplish this task
Assuming you have the data range from A2:E12 and the prefilled unique names starting from A14
Formula:
=countif(ARRAYFORMULA(regexreplace($A$2:$E$12,".\(.*","")),A14)
Copy the formula until the last row
Hope it helps!
I'm sure that others will provide a much more elegant solution but this takes the data as presented in the spreadsheet and can be implemented in just a few minutes.
Paste this formula in Cell F3
=FILTER({A3:A13;B3:B6;C3:C5;D3:D5;E3:E5;A18:A21;B18:B20;C18:C20;D18:D20;E18:E19}, LEN({A3:A13;B3:B6;C3:C5;D3:D5;E3:E5;A18:A21;B18:B20;C18:C20;D18:D20;E18:E19}))
This creates a single column list compiled from the various smaller lists.
Highlight the range of names created in Column F (based on the test data = F3:F41), click Copy,
Highlight cell G3, click Paste special (Paste Values only) - this converts the formula to a list for entries.
Paste this formula in Cell H3 - this removes any data in brackets
=left(G3,iferror(search(" (",G3)-1,len(G3)))
Copy the formula down as many rows as there is data in Column G
Paste this formula in cell I3 - this lists the unique names
=unique(H3:H41)
Paste this formula in cell J3 and copy down as many rows as there is data in Column I - this counts the number of instances of each unique name in the master list.
=COUNTIF(H:H, I3)

Automatically Change Sheet Reference in formula

I have hundreds of sheets, with one master sheet, and I have this formula in my master sheet
=IF(COUNTIF(Sheet2!M$2:M$11,"No")>0, "Y", "N")&COUNTIF(Sheet2!M$2:M$4,"No")&COUNTIF(Sheet2!M$2:M$7,"No")&COUNTIF(Sheet2!M$2:M$11,"No")
which basically grabs the number of yes or nos in a column from the referenced sheet, in this case 'Sheet2', and returns Yes, if there are multiple NOs in the column, and the other arguments just return the count of NOs in the cell ranges.
I just want to drag down the formula in the column it is located in, and have the Sheet reference change from Sheet2 to Sheet3, Sheet4, and so on, but it simply copies it down the column. I've tried looking into it, got some hints with using INDIRECT but I'm returning errors left and right that I'm not sure if I'm on the right track.
EDIT: sample data: https://docs.google.com/spreadsheets/d/1jcbjUs4Ho0LlXF-Olu5NkEw4THqaA0nB5dduYKfx5S8/edit?usp=sharing
I have successfully used below formula to count "No's" using a sheet reference from a cell. Try it out:
=IF(COUNTIF(INDIRECT("Sheet" & A1 & "!" & "A:A");"No")>0;"Y";"N")
You can change the column range to suit your need - I just used column "A" in each sheet and cell "A1" with the sheet reference, in the above case A1 contained the number 2 referring to "Sheet2".
You can replace the Sheet2!M$2:M$11 with the following:
INDIRECT("Sheet"&ROW()-1&"!M$2:M$11")
You have of course to replace the M$2:M$11 with the respective range references.

Resources