简体   繁体   中英

Excel conditional formatting using generic formula

I want to conditionally format cells in Excel. Is it possible to create a generic formula that does the following:

IF the value in column A of the given row = "A" 
    AND the value in the given cell is greater than .1 
    AND the value in the given cell is less than 1
    THEN format the cell with a light grey background color

In the example below, I want the formula to apply to cells B1:K2, but I only want cells E1, I1 and K1 to be highlighted in grey.

在此处输入图片说明

  • Select B1:K[n]. B1 is the active cell.
  • Then, click Home > Conditional Formatting > New Rule.
  • In the New Formatting Rule dialog box, click Use a formula to determine which cells to format.
  • Under Format values where this formula is true, type the formula:

    =AND($A1="A",B1>0.1,B1<1)

  • Click Format.

  • In the Fill box, select your light gray color.
  • Click OK until the dialog boxes are closed.

Greetings

Axel

Select cells E1:F2,I1:I2,K1:K2 (hold down Ctrl while selecting discontinuous range) so the conditional formatting will apply to them.

The cell K1 should have the focus, ie be highlighted with white background, while other selected cells are highlighted with dark background. Insert conditional formatting with following formula:

=($A1="A")*(K1>0.1)*(K1<1)

Tap F5 and when the GoTo dialog opens, type A:K (◄ just like that) into the Reference: box and click OK. You should have columns A through K selected with A1 as the Active Cell .

Create a new Conditional Formatting Rule using the Use a formula to determine which cells to format option and supply the following for Format values where this formula is true:

=AND($A1="A", A1>0.1, A1<1, ISODD(COLUMN(A:A)))

Click Format and select a light=grey Fill then click OK to accept the format and then OK again to create the new CF rule. Your results should resemble the following.

在此处输入图片说明

Edit: Revised from literal interpretation to subjective interpretation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM