If formula and Indirect formula

Ev1lZer0

New Member
Joined
Sep 26, 2022
Messages
38
Office Version
  1. 365
Platform
  1. Windows
I am trying to get color bands on similar dates while having alternating colors on the rest of the table. I started by using an IF formula and had "=IF(A1=A2,B1,NOT(B1))" I also had come conditional formatting involved.
If you need more information, I am using the process shown on the website. "Colour Bands in Excel Table Based on Dates – Contextures Blog"

It works really well, except for when I insert or delete rows. Which will happen frequently.

When I add rows, I get an inconsistent formula error; when I delete rows I get a #REF error. These errors always start BELOW the inserted row.

---

To resolve this, I tried using an INDIRECT formula with the IF formula and ended up with this. =IF((ADDRESS(ROW()-1,COLUMN()-1))=(ADDRESS(ROW(),COLUMN()-1)),B9,NOT(B9)) it does not work. It is now alternating my true false statement incorrectly. in addition, the [value if false] and [value if true] statement is still referencing the cell above which ends up breaking the formula in the same way I stated earlier.
When I add rows, I get an inconsistent formula error; when I delete rows I get a #REF error. These errors always start BELOW the inserted row.

---

lastly, I tried changing the formula to "=IF((ADDRESS(ROW()-1,COLUMN()-1))=(ADDRESS(ROW(),COLUMN()-1)),(ADDRESS(ROW()-1,COLUMN())),NOT(ADDRESS(ROW()-1,COLUMN())))" My hope was to resolve the #REF error and Inconsistent formula error and address the issue where this formula seems to not correctly label true false.

--

I'm pulling out my hair and desperately need help

The end goal... to alternate color bands based on similar dates like the image below. The true and false should be alternated while similar dates should be grouped together and alternated.

And to state again, the solution needs to work when adding or deleting cells - mine in the past have not.

1664221383066.png
 
I deleted the TRUE/FALSE column since it was just a helper column anyway.
Another option without any helper columns
Fluff.xlsm
A
1Date of Trial
209/06/2022
309/06/2022
409/12/2022
509/12/2022
609/12/2022
709/12/2022
809/12/2022
909/12/2022
1009/12/2022
1109/12/2022
1209/12/2022
1309/12/2022
1409/12/2022
1509/12/2022
1609/12/2022
1709/12/2022
1819/09/2022
1919/09/2022
2020/09/2022
2121/09/2022
2222/09/2022
2323/09/2022
2426/09/2022
2526/09/2022
2626/09/2022
2726/09/2022
Main
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A27Expression=MOD(SUMPRODUCT(--($A$2:$A2<>$A$1:$A1)),2)=0textNO
I deleted the TRUE/FALSE column since it was a helper column to begin with and your CF rule did not interact with it. I then used your CF rule and it works. . . until it doesn't.

deleting rows works fine, but when adding new rows, it breaks the CF.

Here is a minisheet that shows what happens when I add a row.
In the example, I set the conditional formatting to highlight in orange just for now and I've deleted the contents of column b for security reasons. Additionally, I have a pink, yellow, and red formatting that is working just fine and is not part of the issue. Lastly, the alternating gray-white color band is what I want for column b and everything after. With that said, the gray-white color band in column a should just be white, while the orange will be gray when I'm done.

2022 Color Coded Watch List 1.xlsx
AB
1Date of Trial Case Number
209/06/22
309/06/22
409/12/22
509/12/22
609/12/22
709/12/22
809/12/22
909/12/22
1009/12/22
1109/12/22
1209/12/22
1309/12/22
1409/12/22
1509/12/22
1609/12/22
1709/12/22
1809/19/22
1909/19/22
2009/20/22
2109/21/22
2209/22/22
2309/23/22
2409/26/22
2509/26/22
2609/26/22
2709/26/22
2809/26/22
2909/26/22
3009/26/22
3109/26/22
3210/03/22
3310/03/22
3410/03/22
3510/03/22
3610/03/22
3710/03/22
3810/03/22
3910/10/22
4010/10/22
4110/10/22
4210/10/22
4310/10/22
4410/10/22
4510/10/22
4610/10/22
4710/17/22
4810/17/22
4910/17/22
5010/17/22
5110/17/22
5210/17/22
5310/17/22
5410/17/22
5510/24/22
5610/24/22
5710/24/22
5810/24/22
5910/24/22
6010/24/22
6110/25/22
6210/31/22
6310/31/22
6410/31/22
6510/31/22
6610/31/22
6710/31/22
6810/31/22
6911/07/22
7011/07/22
7111/07/22
7211/07/22
7311/07/22
7411/07/22
7511/07/22
7611/07/22
7711/07/22
7811/14/22
7911/14/22
8011/14/22
8111/14/22
8211/14/22
8311/14/22
8411/14/22
8511/14/22
8611/14/22
8711/14/22
8811/14/22
8911/14/22
9011/21/22
9111/21/22
9211/21/22
9311/28/22
9411/28/22
9511/28/22
9612/12/22
9712/12/22
9812/12/22
9912/12/22
10012/12/22
10112/19/22
10201/09/23
10301/09/23
10401/17/23
10501/17/23
10601/17/23
10701/23/23
10801/23/23
10901/23/23
11001/30/23
11101/30/23
11202/06/23
11302/06/23
11402/06/23
11502/13/23
11602/13/23
11702/13/23
11802/13/23
11902/21/23
12002/27/23
12102/27/23
12202/27/23
2022 Trial Calendar
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A122Expression=MOD(SUMPRODUCT(--($A$2:$A2<>$A$1:$A1)),2)=0textNO
B1:M2,B3:C3,J3:M3,E3:H3,B4:M1048576Expression=#REF!="Pink"textNO
B1:M2,B3:C3,J3:M3,E3:H3,B4:M1048576Expression=#REF!="Yellow"textNO
B1:M2,B3:C3,J3:M3,E3:H3,B4:M1048576Expression=#REF!="Red"textNO
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
In what way is it "breaking" the CF, the data you've posted looks fine.
 
Upvote 0
I deleted the TRUE/FALSE column since it was just a helper column anyway.

I deleted the TRUE/FALSE column since it was a helper column to begin with and your CF rule did not interact with it. I then used your CF rule and it works. . . until it doesn't.

deleting rows works fine, but when adding new rows, it breaks the CF.

Here is a minisheet that shows what happens when I add a row.
In the example, I set the conditional formatting to highlight in orange just for now and I've deleted the contents of column b for security reasons. Additionally, I have a pink, yellow, and red formatting that is working just fine and is not part of the issue. Lastly, the alternating gray-white color band is what I want for column b and everything after. With that said, the gray-white color band in column a should just be white, while the orange will be gray when I'm done.

2022 Color Coded Watch List 1.xlsx
AB
1Date of Trial Case Number
209/06/22
309/06/22
409/12/22
509/12/22
609/12/22
709/12/22
809/12/22
909/12/22
1009/12/22
1109/12/22
1209/12/22
1309/12/22
1409/12/22
1509/12/22
1609/12/22
1709/12/22
1809/19/22
1909/19/22
2009/20/22
2109/21/22
2209/22/22
2309/23/22
2409/26/22
2509/26/22
2609/26/22
2709/26/22
2809/26/22
2909/26/22
3009/26/22
3109/26/22
3210/03/22
3310/03/22
3410/03/22
3510/03/22
3610/03/22
3710/03/22
3810/03/22
3910/10/22
4010/10/22
4110/10/22
4210/10/22
4310/10/22
4410/10/22
4510/10/22
4610/10/22
4710/17/22
4810/17/22
4910/17/22
5010/17/22
5110/17/22
5210/17/22
5310/17/22
5410/17/22
5510/24/22
5610/24/22
5710/24/22
5810/24/22
5910/24/22
6010/24/22
6110/25/22
6210/31/22
6310/31/22
6410/31/22
6510/31/22
6610/31/22
6710/31/22
6810/31/22
6911/07/22
7011/07/22
7111/07/22
7211/07/22
7311/07/22
7411/07/22
7511/07/22
7611/07/22
7711/07/22
7811/14/22
7911/14/22
8011/14/22
8111/14/22
8211/14/22
8311/14/22
8411/14/22
8511/14/22
8611/14/22
8711/14/22
8811/14/22
8911/14/22
9011/21/22
9111/21/22
9211/21/22
9311/28/22
9411/28/22
9511/28/22
9612/12/22
9712/12/22
9812/12/22
9912/12/22
10012/12/22
10112/19/22
10201/09/23
10301/09/23
10401/17/23
10501/17/23
10601/17/23
10701/23/23
10801/23/23
10901/23/23
11001/30/23
11101/30/23
11202/06/23
11302/06/23
11402/06/23
11502/13/23
11602/13/23
11702/13/23
11802/13/23
11902/21/23
12002/27/23
12102/27/23
12202/27/23
2022 Trial Calendar
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A122Expression=MOD(SUMPRODUCT(--($A$2:$A2<>$A$1:$A1)),2)=0textNO
B1:M2,B3:C3,J3:M3,E3:H3,B4:M1048576Expression=#REF!="Pink"textNO
B1:M2,B3:C3,J3:M3,E3:H3,B4:M1048576Expression=#REF!="Yellow"textNO
B1:M2,B3:C3,J3:M3,E3:H3,B4:M1048576Expression=#REF!="Red"textNO
In what way is it "breaking" the CF, the data you've posted looks fine.
I copied the wrong info.
See below for the correction.

I'm sorry, the example I included is working fine. Here is the example after I add two Rows. To be clear, rows 4 & 19 are new. You can see the changes it made to the CF. The "applies to" section has been drastically changed, and it added a new CF rule.
2022 Color Coded Watch List 1.xlsx
AB
1Date of Trial Case Number
209/06/22
309/06/22
409/11/22
509/12/22
609/12/22
709/12/22
809/12/22
909/12/22
1009/12/22
1109/12/22
1209/12/22
1309/12/22
1409/12/22
1509/12/22
1609/12/22
1709/12/22
1809/12/22
1909/12/22
2009/19/22
2109/19/22
2209/20/22
2309/21/22
2409/22/22
2509/23/22
2609/26/22
2709/26/22
2809/26/22
2909/26/22
3009/26/22
3109/26/22
3209/26/22
3309/26/22
3410/03/22
3510/03/22
3610/03/22
3710/03/22
3810/03/22
3910/03/22
4010/03/22
4110/10/22
4210/10/22
4310/10/22
4410/10/22
4510/10/22
4610/10/22
4710/10/22
4810/10/22
4910/17/22
5010/17/22
5110/17/22
5210/17/22
5310/17/22
5410/17/22
5510/17/22
5610/17/22
5710/24/22
5810/24/22
5910/24/22
6010/24/22
6110/24/22
6210/24/22
6310/25/22
6410/31/22
6510/31/22
6610/31/22
6710/31/22
6810/31/22
6910/31/22
7010/31/22
7111/07/22
7211/07/22
7311/07/22
7411/07/22
7511/07/22
7611/07/22
7711/07/22
7811/07/22
7911/07/22
8011/14/22
8111/14/22
8211/14/22
8311/14/22
8411/14/22
8511/14/22
8611/14/22
8711/14/22
8811/14/22
8911/14/22
9011/14/22
9111/14/22
9211/21/22
9311/21/22
9411/21/22
9511/28/22
9611/28/22
9711/28/22
9812/12/22
9912/12/22
10012/12/22
10112/12/22
10212/12/22
10312/19/22
10401/09/23
10501/09/23
10601/17/23
10701/17/23
10801/17/23
10901/23/23
11001/23/23
11101/23/23
11201/30/23
11301/30/23
11402/06/23
11502/06/23
11602/06/23
11702/13/23
11802/13/23
11902/13/23
12002/13/23
12102/21/23
12202/27/23
12302/27/23
12402/27/23
2022 Trial Calendar
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A4,A6:A19,A21:A124Expression=MOD(SUMPRODUCT(--($A$2:$A2<>$A$1:$A1)),2)=0textNO
B1:M2,B3:C4,J3:M4,E3:H4,B5:M1048576Expression=#REF!="Pink"textNO
B1:M2,B3:C4,J3:M4,E3:H4,B5:M1048576Expression=#REF!="Yellow"textNO
B1:M2,B3:C4,J3:M4,E3:H4,B5:M1048576Expression=#REF!="Red"textNO
A5,A20Expression=MOD(SUMPRODUCT(--($A$2:$A5<>$A$1:$A3)),2)=0textNO
 
Upvote 0
Ok, how about
Excel Formula:
=ISEVEN(MATCH($A2,UNIQUE($A$2:$A$124),0))
 
Upvote 0
Solution
It worked!
Ok, how about
Excel Formula:
=ISEVEN(MATCH($A2,UNIQUE($A$2:$A$124),0))
Part 2 of the issue, which is more minor, but still important.
The alternating color as you see in A32-A38 I just want it to be blue (again temporary color for now).
So that way you would end up with alternating color bands of orange and blue.

This screenshot has other CF which are causing some of the red cells.
1664301571515.png


Desired outcome
1664301604870.png
 
Upvote 0
For the blue you can use the same formula just change iseven to isodd.
 
Upvote 0
This is wonderful!

I have spent hours on this and you came swooping in with an alternative formula! Thank you! :)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
With the CF not holding while I'm filtered in the table, I'm confident this will be fine. But if I wanted to make the CF hold true even while filtering, can this be done with this formula and a VBA that does something?

I briefly looked into @cmowla's formula, but it got too complicated and I couldn't figure out what exactly wasn't working.
 
Upvote 0
With a helper column like
Fluff.xlsm
ABC
1Date of TrialColumn1Column2
209/06/20221
309/06/20221
510/09/20221
712/09/20221
812/09/20221
912/09/20221
1012/09/20221
1112/09/20221
1212/09/20221
1312/09/20221
1412/09/20221
1512/09/20221
1612/09/20221
1712/09/20221
1812/09/20221
1912/09/20221
2012/09/20221
2113/09/20221
2219/09/20221
2319/09/20221
2420/09/20221
2521/09/20221
2626/09/20221
2726/09/20221
2826/09/20221
2926/09/20221
3028/09/20221
3130/09/20221
3201/10/20221
3302/10/20221
3403/10/20221
Main
Cell Formulas
RangeFormula
B2:B3,B5,B7:B34B2=SUBTOTAL(103,[@[Date of Trial]])
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:C34Expression=ISODD(MATCH($A2,UNIQUE(FILTER($A$2:$A$34,$B$2:$B$34=1)),0))textNO
A2:C34Expression=ISEVEN(MATCH($A2,UNIQUE(FILTER($A$2:$A$34,$B$2:$B$34=1)),0))textNO
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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