Conditional Formatting a row only for cells to right based on cells to left

PETTEXCEL

New Member
Joined
Feb 26, 2018
Messages
4
Hello,

I am familiar with conditional formatting, but this has me perplexed. I have a portfolio table that includes Projects on the Y-axis and Quarters along the X-axis on top. Our project managers enter in the number of hours they invest into each project by quarter.

Goal:
  • Enter "complete" in the cell aligned to the Project and Quarter.

  • Cell containing "complete" turns gray
  • All blank cells to the right (future quarters) turn gray
  • Blank cells to the left would not be affected by this conditional formatting, because a project may not have initiated yet.

I have attempted multiple formulas within conditional formatting with no success (Search, If/Then, AND). The Cell Value contains option works for "completed". If I include the Format only blank cells, then cells to the right and left of completed turn gray.

Let me know if I can be more clear.

Thanks.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Welcome to the board.

Perhaps this combination of two CF rules:

Assuming your table starts in A1 with Y-Axis A2 and down, X-Axis B1 and across(otherwise, change ranges to suit your data):

=B2="completed"
=AND(COUNTIF(B2:$G2,"completed")<1,COUNTIF($B2:$G2,"completed")=1)
 
Last edited:
Upvote 0
Welcome to the board.

Perhaps this combination of two CF rules:

Assuming your table starts in A1 with Y-Axis A2 and down, X-Axis B1 and across(otherwise, change ranges to suit your data):

=B2="completed"
=AND(COUNTIF(B2:$G2,"completed")<1,COUNTIF($B2:$G2,"completed")=1)

This worked perfectly. Do you mind breaking down the countif < scenario for me?
 
Upvote 0
Glad it worked.

So, originally I tried COUNTIF(B2:$G2,"completed")>=1. This ended up highlighting just the rows where completed actually was, but from left to right up to the cell containing completed.

I changed the comparison to <1 which ended up highlighting the rows left to right, but starting at the cell containing "completed". This also highlighted any row where "completed" did not exist.

The second COUNTIF eliminates the rows where "completed" does not exist.

Now, the other reason this works this way is the cell locking. B2:$G2

As CF "drags" the formula across the row, the range that is being checked for "completed" is getting smaller, therefor eliminating the beginning cells of each row as the formula goes along.
 
Upvote 0
Ok that's helpful. I understand the less than placement now and how it eliminated rows where "completed" did not exist.

What I'm still unclear on is cell locking. Are you saying that because you placed the $ before G2 that this told the CF to not apply to any cells between B2:G2 where the condition does not exist?
 
Upvote 0
Not quite. The $ locks the cell reference so that when you drag/copy a formula across rows/down columns, that reference will not change. You can lock a cell by row (A$1), or column ($A1) or both ($A$1). CF is smart will automatically adjust the formula to suit each cell in the range it is applied to.

For example: If I were to apply a rule of highlighting a cell if the value equals 1, and highlighted the range A1:B5, I would use a formula like this: =A1=1. Per the following table, this is how CF will interpret this formula for each cell in the selected range.

AB
1=A1=1=B1=1
2=A2=1=B2=1
3=A3=1=B3=1
4=A4=1=B4=1
5=A5=1=B5=1

<tbody>
</tbody>

Now, this next table will show how CF interprets the cell locking in the first COUNTIF I used:
ABCDEF
1X-axis
2Y-axis=COUNTIF(B2:$G2 ...=COUNTIF(C2:$G2 ...=COUNTIF(D2:$G2 ...=COUNTIF(E2:$G2 ...=COUNTIF(F2:$G2 ...
3=COUNTIF(B3:$G3 ...=COUNTIF(C3:$G3 ...=COUNTIF(D3:$G3 ...=COUNTIF(E3:$G3 ...=COUNTIF(F3:$G3 ...

<tbody>
</tbody>

By the time the formula is applied to column G, the cell reference is G2:$G2, so it is only checking 1 cell at the end of each row.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top