简体   繁体   English

如果包含来自另一个单元格的文本,则工作表条件格式

[英]Sheets conditional formatting if contains text from another cell

I have a Google sheet which has a column for business name (A) and a column for city (B).我有一个 Google 工作表,其中有一列用于公司名称 (A) 和一列用于城市 (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.如果城市名称和公司名称完全相同=$A$2:$A=$B2 ,我知道该怎么做,但如果只有一部分匹配,我会努力弄清楚该怎么做。 Putting an asterisk before $B2 broke the formula.在 $B2 破坏公式之前放置一个星号。

Use SEARCH :使用SEARCH

=AND(ISNUMBER(SEARCH(TRIM(B2),A2)),B2<>"")

with range starting from A2 .范围从A2开始。 You search if A2 contains text from B2 and returns starting number if found.您搜索A2是否包含B2中的文本,如果找到则返回起始编号。 So if it is a number then ISNUMBER returns TRUE所以如果它是一个数字那么ISNUMBER返回TRUE

Result:结果:

在此处输入图像描述

=REGEXMATCH ($A2,$B2) would do the work too! =REGEXMATCH ($A2,$B2) 也可以完成这项工作!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于条件格式的谷歌表格公式:“如果单元格包含精确的文本文本”然后 - Google Sheets formula for conditional formatting: “if cell contains exact text text” then 一个单元格中的 Google 表格条件格式文本会影响另一个单元格 - Google Sheets conditional formatting text in one cell effects another cell Google 表格 - 条件格式 - 基于另一个单元格文本的一个单元格 - Google Sheets - Conditional Formatting - One Cell Based on Another Cell Text Google 表格 - 条件格式:突出显示包含在列表中找到的文本的单元格(动态列表) - Google Sheets - Conditional Formatting: Highlight cell that contains text found in list (dynamic list) Google 表格:单元格中的条件格式基于另一个单元格中的文本,而不是数字值 - Google Sheets: Conditional Formatting in Cell based on TEXT in another Cell, Not Number Value Google表格条件格式,如果单元格值包含范围内的值 - Google Sheets Conditional Formatting if cell value contains value in range Google 表格:基于单元格的条件格式 - 如果包含字符串 - Google Sheets: Conditional Formatting Based On a Cell - If Contains String Google表格中的条件格式IF单元格包含任何空格 - Conditional formatting in Google Sheets IF cell contains any spaces Google表格中的条件格式可继承其他单元格的格式 - Conditional formatting in google sheets to inherit formatting from other cell 基于另一个单元格文本的条件格式 - Conditional formatting based on another cell's text
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM