Filling backcolor cells color based on the color of a cell

jgalas

Board Regular
Joined
Jul 4, 2011
Messages
111
Office Version
  1. 2013
Platform
  1. Windows
I want, based on the color of one cell (red), to fill the 5 cells below (pink). As picture.

The cell background (red) is defined by CF.
=IF($A81="calendar";IF(MONTH(Calendar!$F$23)=$C82;DAY(Calendar!$F$23);-1);IF($A81="calendar_bi";IF(MONTH( Calendar!$AK$23)=$C82;DAY(Calendar!$AK$23);-1)))

It will be applied to several rows.

Thank you in advance for any help

1717964260840.png
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Set CF rules for the cells underneath using the same formula as used for the primary cell.

Not your exact example. (Sorry, I'm not going to recreate your scenario from scratch. You can share a copy of your workbook to a file share site, if you like).

Book1
ABCDEFG
1
2ColumnDeveloping CF Rule
3ABCD1223TRUE
4dfadfTRUE
5fgfTRUE
6dsfgTRUE
7hggfTRUE
8
Sheet10
Cell Formulas
RangeFormula
G3:G7G3=SUM($D$3:$F$3)=17
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:A7Expression=SUM($D$3:$F$3)=17textNO
A3Expression=SUM($D$3:$F$3)=17textNO
 
Last edited:
Upvote 0
Set CF rules for the cells underneath using the same formula as used for the primary cell.

Not your exact example. (Sorry, I'm not going to recreate your scenario from scratch. You can share a copy of your workbook to a file share site, if you like).

Book1
ABCDEFG
1
2ColumnDeveloping CF Rule
3ABCD1223TRUE
4dfadfTRUE
5fgfTRUE
6dsfgTRUE
7hggfTRUE
8
Sheet10
Cell Formulas
RangeFormula
G3:G7G3=SUM($D$3:$F$3)=17
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:A7Expression=SUM($D$3:$F$3)=17textNO
A3Expression=SUM($D$3:$F$3)=17textNO

awoohaw, thank you for your answer but it doesn't work that way.
It fills all cells with the background color defined in CF.

What I need is a way to detect the background color of a cell (red) and fill the 5 below with the same color.
 
Upvote 0
I'm not sure what you mean compared to your initial question. I used blue instead of pink, my error there.
As I said. in my original post. The rule you need to use is the the same rule, but with different relative references.

what worksheet and cell is the red "10" in?
 
Upvote 0
You cannot use the cell color for Conditional Formatting.
(There are posts somewhere where people can do it with VBA - but just using the same rule to apply a different color to different cells will work!)

Please take a look at how Minda Treacy approaches Conditional Formatting:

 
Upvote 0
I'm not sure what you mean compared to your initial question. I used blue instead of pink, my error there.
As I said. in my original post. The rule you need to use is the the same rule, but with different relative references.

what worksheet and cell is the red "10" in?
hello
I appreciate your response.
The problem isn't with the color you used ;)
Maybe I didn't express myself well.

I have range ("D9:AF9"), range ("D15:AF15"), ... in which some cells are filled with red automatically by CF.
What I want is to detect the cell filled with red (it can be any cell and they can change) and fill red (or pink, ...) in the next 5 below them.

I've been working on it and got this code:
Sub DetectCorFill()
Dim rng As Range
Dim cell As Range

Set rng = Union(Range("D9:AF9"), Range("D15:AF15"))

For Each cell In rng
If cell.DisplayFormat.Interior.Color = RGB(255, 0, 0) Then
Range(cell.Offset(1, 0), cell.Offset(5, 0)).Interior.Color = RGB(255, 0, 0)
End If
Next cell
End Sub

It works!

However, when the cells filled with red change into range ("D9:AF9"), range ("D15:AF15"),..... the 5 bellow cells formatted remain.

Any tips?
Thank you for your help.
 
Upvote 0
Your VBA skills are better than mine.

Whenever I use conditional formatting based on how a particular cell is formatted I use the same rule.
It is that simple. You have some complexities in your CF formula, but that should make no difference.
Assume cell X999 is formatted because Z49 + Y9000 + Q42 = 1000.... the you should be able to put that
CF rule in ANY cell's CF that you want.

while giving me your range references was helpful... it does not answer my specific question of what cell is the red 10 in?
 
Upvote 0
Your VBA skills are better than mine.

Whenever I use conditional formatting based on how a particular cell is formatted I use the same rule.
It is that simple. You have some complexities in your CF formula, but that should make no difference.
Assume cell X999 is formatted because Z49 + Y9000 + Q42 = 1000.... the you should be able to put that
CF rule in ANY cell's CF that you want.

while giving me your range references was helpful... it does not answer my specific question of what cell is the red 10 in?
The red 10 is in J15
 
Upvote 0
J15 backcolor is red with CF when:
=SE($A15="calendario";SE(MÊS(Calendario!$F$16)=$C16;DIA(Calendario!$F$16);-1);SE($A15="calendario_bi";SE(MÊS(Calendario!$AK$16)=$C16;DIA(Calendario!$AK$16);-1)))
is TRUE
 
Upvote 0
thanks can you do me a favor as a proof of concept.
Put the CF formula for cell J15, in cells J16:J20? do not copy and paste.
IF cell J15 is still [RED], if not go one in the row that is.
Go to your CF rule editor for cell J15, and copy it the rule formula.
Then select J16:J20 and press F2, paste the CF formula in, be sure it includes the "=" sign. Then press CNTL-ENTER.
If you get all TRUES, then you have a CF rule that works. Just enter a new rule for those cells, paste the formula and select a fill color.

So... Based upon your formula above.
go to cell J16,
click conditional formatting, new rule based on formula
paste this in the formula bar:
Excel Formula:
=SE($A15="calendario";SE(MÊS(Calendario!$F$16)=$C16;DIA(Calendario!$F$16);-1);SE($A15="calendario_bi";SE(MÊS(Calendario!$AK$16)=$C16;DIA(Calendario!$AK$16);-1)))
(Yes, it is the same formula)
Select the FILL
Click OK until you get out.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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