Solution for Excel 2016 number of consecutive cells in row = 3 does not quite work

Gregory123987

New Member
Joined
Jun 23, 2020
Messages
33
Office Version
  1. 2016
Platform
  1. Windows
I had needed a solution to automatically provide conditional formatting if there were consecutive days with values. Unfortunately, the solution that was found did not highlight the 3rd consecutive cell for the current month if there were more than 2 cells ending the previous month. The 9 hidden columns to the left of column M have a value if column J (previous month) has a value.

The same issue applies for 5 and 10 cells as well, but I can fix this myself if someone can help with a solution for the 3rd consecutive cell issue I just described. A link to the previous thread is below.

FYI - I did not do a proper job of testing it as time was of the essence. It has been a year since then and I noticed the issue as I was making changes to the spreadsheet. Thank you in advance for your help.

It took me a while but I managed to figure out a solution. Here it for your info. Thanks for your help.

Added hidden columns, View attachment 19961

Expanded conditional formatting to include applicable columns, wrapped Column with And and added cell reference such as the following to change from
=COLUMN()=(MIN(IF(($M18:$AG18<>"")*($M18:$AH18<>"")*($M18:$AI18<>""),COLUMN($M$16:$AG$16)+2))) to
=AND($J18<3,(COLUMN()=(MIN(IF(($T18:$AP18<>"")*($U18:$AQ18<>"")*($V18:$AR18<>""),COLUMN($T$16:$AP$16)+2)))))
 
I haven't done a lot of testing but think that this is on the right track. The hidden columns W:AE are not needed for this. The number of days from the previous month is taken directly from column J (copied to BG in the example for easier visual reference).

The formulas for Blue, Yellow, and Orange are identical apart from the 3, 5, or 10 at the very end.
Manexcel.xlsx
AFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBG
22Column J
231111111111111111111110
2411111111111111111111111110
2511111111111111111111111112
2611111111111111111111111113
2711111111111111111111111114
28111111111111111111111111119
291111111111111111111111111131
Sheet11
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AF23:BE34Expression=IF(AF23="","",IF(COUNTBLANK($AF23:AF23),IF(COUNT(OFFSET(AF23,,,,MATCH(2,1/($AF23:AF23=""))-COLUMNS($AF23:AF23)))>$J23+COUNT(OFFSET($AF23,,,,MATCH(TRUE,$AF23:AF23="",0))),COUNT(OFFSET(AF23,,,,MATCH(2,1/($AF23:AF23=""))-COLUMNS($AF23:AF23))),""),MOD(IF($J23<10,$J23)+COUNT($AF23:AF23)-1,IF(COLUMNS($AF3:AF3)<10,10,1E+100))+1))=10textNO
AF23:BE34Expression=IF(AF23="","",IF(COUNTBLANK($AF23:AF23),IF(COUNT(OFFSET(AF23,,,,MATCH(2,1/($AF23:AF23=""))-COLUMNS($AF23:AF23)))>$J23+COUNT(OFFSET($AF23,,,,MATCH(TRUE,$AF23:AF23="",0))),COUNT(OFFSET(AF23,,,,MATCH(2,1/($AF23:AF23=""))-COLUMNS($AF23:AF23))),""),MOD(IF($J23<10,$J23)+COUNT($AF23:AF23)-1,IF(COLUMNS($AF3:AF3)<10,10,1E+100))+1))=5textNO
AF23:BE34Expression=IF(AF23="","",IF(COUNTBLANK($AF23:AF23),IF(COUNT(OFFSET(AF23,,,,MATCH(2,1/($AF23:AF23=""))-COLUMNS($AF23:AF23)))>$J23+COUNT(OFFSET($AF23,,,,MATCH(TRUE,$AF23:AF23="",0))),COUNT(OFFSET(AF23,,,,MATCH(2,1/($AF23:AF23=""))-COLUMNS($AF23:AF23))),""),MOD(IF($J23<10,$J23)+COUNT($AF23:AF23)-1,IF(COLUMNS($AF3:AF3)<10,10,1E+100))+1))=3textNO
AF23:BE34Expression=AND(AF23<>"",($J23+COUNT(AF23:$AF23))=1)textNO
 
Upvote 0
Solution

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Wow. this is elegant. I just posted the conditional formulas and it all seems to work. Except for the red.
=AND(AF23<>"",($J23+COUNT(AF23:$AF23))=1) | changed to =AND(AF23<>"",($J23+COUNT(AF23:AF23))=1) Removed the last $, and that seemed to work.
 
Upvote 0
@jasonb75, just to be sure, part of the formula seems to be incorrect, could you confirm? It seems to be outside the range of the worksheet example.

=IF(AF23="","",IF(COUNTBLANK($AF23:AF23),IF(COUNT(OFFSET(AF23,,,,MATCH(2,1/($AF23:AF23=""))-COLUMNS($AF23:AF23)))>$J23+COUNT(OFFSET($AF23,,,,MATCH(TRUE,$AF23:AF23="",0))),COUNT(OFFSET(AF23,,,,MATCH(2,1/($AF23:AF23=""))-COLUMNS($AF23:AF23))),""),MOD(IF($J23<10,$J23)+COUNT($AF23:AF23)-1,IF(COLUMNS($AF3:AF3)<10,10,1E+100))+1))=3

Should this be $AF23:AF23

EDIT: PS I used the Yellow, but it is applicable to all 3.
 
Upvote 0
Should this be $AF23:AF23
Ideally, yes. It is not essential but I would recommend correcting it to avoid errors later.

The COLUMNS() function only serves as a counter, as long as it starts with a single cell, the $ symbol is correctly placed, and you don't insert / delete any rows / cells / columns then it will be fine.
Inserting / deleting can cause errors depending on where it is done relative to the position of the formula cells.
 
Upvote 0

Forum statistics

Threads
1,215,766
Messages
6,126,761
Members
449,336
Latest member
p17tootie

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