conditional formatting: alternate rules on a condition

Berrett

Board Regular
Joined
Aug 6, 2004
Messages
249
I am using:

=MOD(ROW(),2)=0

... to alternate row colors in a spreadsheet. However, what I'd really like to do is have the row columns alternate colors IF there is a date in row 6. If there is no date in row 6 I'd like all of the rows to just be a light gray, or maybe just have no formatting at all.

Can this be done?

BTW: Row 6 is not included in the conditionally formatted rows. The conditionally formatted rows 9-109.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I am using:

=MOD(ROW(),2)=0

... to alternate row colors in a spreadsheet. However, what I'd really like to do is have the row columns alternate colors IF there is a date in row 6. If there is no date in row 6 I'd like all of the rows to just be a light gray, or maybe just have no formatting at all.

Can this be done?

BTW: Row 6 is not included in the conditionally formatted rows. The conditionally formatted rows 9-109.
Where in row 6?

Just add a test to your current formula.

=AND(COUNT($A$6),MOD(ROW(),2)=0)
 
Upvote 0
I have not tried your solution yet, but you asked where Row 6 was. It looks like this:

http://www.flickr.com/photos/61932465@N00/5808357937/

I want conditional formatting on the columns that have a date in row 6, and nothing in the columns that have nothing in row 6. (Actually, there's a formula in row 6 -- so it's not blank). I hope that helps. I will check out your solution now.
 
Upvote 0
Maybe I'm misapplying it, but I can't get that solution to work. I tried it on a single column (changing a6 to m6), and I tried it on a group of columns. But no luck. Now with the picture to clarify the situation, is there a better solution?
 
Upvote 0
Maybe I'm misapplying it, but I can't get that solution to work. I tried it on a single column (changing a6 to m6), and I tried it on a group of columns. But no luck. Now with the picture to clarify the situation, is there a better solution?
What version of Excel are you using?
 
Upvote 0
The condition should not have the dollar-sign in front of the A:
=AND(COUNTA(A$6)>0,MOD(ROW(),2)=0)
because you want it to ask about row 6 in the current column, not row 6 in column A. I also changed to the COUNTA function, which more reliably distinguishes blank from non-blank, and added ">0" to return a Boolean rather than an integer.

This should be the condition only in column A -- in column B it should be:
=AND(COUNTA(B$6)>0,MOD(ROW(),2)=0)
etc.
 
Upvote 0
The condition should not have the dollar-sign in front of the A:
=AND(COUNTA(A$6)>0,MOD(ROW(),2)=0)
because you want it to ask about row 6 in the current column, not row 6 in column A. I also changed to the COUNTA function, which more reliably distinguishes blank from non-blank, and added ">0" to return a Boolean rather than an integer.

This should be the condition only in column A -- in column B it should be:
=AND(COUNTA(B$6)>0,MOD(ROW(),2)=0)
etc.
COUNTA is not a very robust test for a date!

COUNT or ISNUMBER would be more robust.
 
Upvote 0
I got a solution that worked - Thank you very much to both of you!

Because row 6 is never truly blank (it has a formula in it), the counta and the ">0" did not work. However, when I modified it to look like this:

=AND(NOT(I$6=""),MOD(ROW(),2)=0)

... it worked. I'm not smart enough to know what the difference is or why this was successful, but it's working. Thanks a lot. I would have never found this solution without your input.
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

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