简体   繁体   English

如果单元格行包含“ z”,则有条件地格式化A列

[英]Conditionally format column A if cell row contains “z”

I want to highlight cells in column A (using the conditional formatting tool) if the cell's corresponding row contains the letter z anywhere within that row. 如果单元格的对应行在该行中的任何位置包含字母z ,我想突出显示A列中的单元格(使用条件格式设置工具)。 I want to do this so I can sort data to the top if it is highlighted in column A. 我想这样做,因此如果数据在A列中突出显示,我可以将其排序到顶部。

I'm using the formula: 我正在使用公式:

=COUNTIF($A1:$AA1,"*z*") 

But I don't want to highlight the entire row, just the corresponding cell in column A for that row. 但是我不想突出显示整个行,而仅突出显示该行的A列中的相应单元格。

What is the formula to do this? 这样做的公式是什么?

Select ColumnA then HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true: : 选择ColumnA,然后选择HOME>样式-条件格式,新规则..., 使用公式确定要格式化的单元格,在此公式为true的情况下设置值的 格式

=COUNTIF($A1:$AA1,"*z*")>0

Format... , select highlighting OK, OK. 格式... ,选择突出显示的确定,确定。

This will apply only to Column A (because of the selection). 这仅适用于列A(由于选择)。

This seemed to work for me when testing with a 3x3 cell table: 在使用3x3单元格表进行测试时,这似乎对我有用:

  1. Highlight A1:A3 突出显示A1:A3
  2. Conditional Formatting>New Rule>Use a formula to determine which cells to format 条件格式>新规则>使用公式来确定要格式化的单元格
  3. Formula: 式:

    =COUNTIF($B1:$C1," z ") = COUNTIF($ B1:$ C1,“ z ”)

Then only cells in A were highlighted. 然后,仅突出显示A中的单元格。

"I want to do this so I can sort data to the top if it is highlighted in column A." “我想这样做,以便如果数据在A列中突出显示,则可以将其排序到顶部。”

Ok, first of all, you don't need to use conditional formatting to sort. 好的,首先,您不需要使用条件格式进行排序。 Second of all you wouldn't want to reference A1 in your formula =COUNTIF($A1:$AA1,"z") - it is a circular reference and any formula you put in column A would not return "z" anyways because you are using it for your COUNTIF formula. 第二,您不想在公式=COUNTIF($A1:$AA1,"z")引用A1-这是一个循环引用,您放在A列中的任何公式都不会返回“ z”,因为您正在将其用于您的COUNTIF公式。

The formula you want to use is: 您要使用的公式是:

=IF(COUNTIF($B1:$AA1,"z")>0,1,0)

If you want to look for any row that contains az anywhere in a string you would want to do a wildcard countif: 如果要查找字符串中任意位置包含z的任何行,则需要执行通配符计数:

=IF(COUNTIF($B1:$AA1,"*z")>0,1,0)

Then you can just sort on column A for all your data - high to low. 然后,您可以对所有数据从A列进行排序-从高到低。

Basically you have demonstrated a basic misunderstanding of how to sort in excel(no offense). 基本上,您已经表现出对如何按excel排序的基本误解(无冒犯)。 This should help you. 这应该对您有帮助。 Good Luck. 祝好运。

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

相关问题 根据第一个单元格有条件地对单元格进行格式化 - Format cells in row conditionally based on the first cell 有条件地根据列中的值格式化一个单元格 - Conditionally format one cell based on values in a column 如何根据仅一个单元格的值有条件地格式化整个行? - How to conditionally format whole row depending on ONLY ONE cell value? 如何根据第一个单元格是否为空来有条件地格式化 Excel VBA 中的一行? - How to conditionally format a row in Excel VBA based on if first cell is empty? Excel - 如果不包含特定文本且非空白,则有条件地格式化列中的单元格 - Excel - Conditionally format cell in column if NOT containing specific text and is NOT BLANK 在具有行,列格式的单元格中复制索引公式 - Copy Index formular in cell with row,column format 如何根据每个单元格的值和固定单元格的值有条件地格式化VBA中的列? - How do I conditionally format a column in VBA based on each cell's value and a fixed cell's value? SUMIF在同一行的某一列中的单元格包含特定文本 - SUMIF a cell on the same row, in a certain column, contains a specific text 如果一列中的单元格包含特定字符串,如何隐藏行 - How to hide a row if a cell in one column contains a certain string Excel 如果单元格值包含列名,则行中的平均值 - Excel average of values in row if cell value contains column names
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM