Highlight dates in row not column

ozbeachbum

Board Regular
Joined
Jun 3, 2015
Messages
159
Office Version
  1. 2021
Platform
  1. Windows
Hi All,
I am endeavouring to highlight the current date and the next 7 days, the following formula being used in Conditional Formatting [=AND($A2-TODAY()>=0, $A2-TODAY()<=7) A2 Being the first of the month] this works when the dates are listed in a column but not in a row and I have searched the net to find a solution to no avail.
Any assistance would be greatly appreciated.
Cheers,
Dave.
Column
date cf.xlsx
A
2Sat 01-Oct-22
3Sun 02-Oct-22
4Mon 03-Oct-22
5Tue 04-Oct-22
6Wed 05-Oct-22
7Thu 06-Oct-22
8Fri 07-Oct-22
9Sat 08-Oct-22
10Sun 09-Oct-22
11Mon 10-Oct-22
12Tue 11-Oct-22
13Wed 12-Oct-22
14Thu 13-Oct-22
15Fri 14-Oct-22
Column
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A15Expression=AND($A2-TODAY()>=0, $A2-TODAY()<=7)textNO


Row
date cf.xlsx
ABCDEFGHIJKLMNOP
2Sat 01-Oct-22Sun 02-Oct-22Mon 03-Oct-22Tue 04-Oct-22Wed 05-Oct-22Thu 06-Oct-22Fri 07-Oct-22Sat 08-Oct-22Sun 09-Oct-22Mon 10-Oct-22Tue 11-Oct-22Wed 12-Oct-22Thu 13-Oct-22Fri 14-Oct-22Sat 15-Oct-22Conditional Formatting =AND($A2-TODAY()>=0, $A2-TODAY()<=7)
Row
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:O2Expression=AND($A2-TODAY()>=0, $A2-TODAY()<=7)textNO
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Change $A2 to A$2 in your formula. Actually you can remove the $ completely if you are just doing the one row.
 
Upvote 0
Solution
Would it help for me to explain why you need to make that change?
 
Upvote 0
The original formula was

Excel Formula:
=AND($A2-TODAY()>=0, $A2-TODAY()<=7)

The $ in front of the A is an absolute reference. That means no matter what cell you are formatting, use the value in column A to determine whether to format it. In your case you are just formatting column A anyway. But if you extended this formula into other columns, all columns would be formatted based on the value in column A.

When you tried to use the same formula to format a row, all cells in the row were still tied to column A even though you now really want to format based on each cell. That is, cell B2 will be formatted based on A2, C2 will be formatted based on A2, and so on. So if you remove the $ each cell will be formatted based on its own value, instead of the value in column A.

This same principle applies to formulas in your worksheet. With a $, it always refers to that row or that column. Without it, it refers to a relative row or column. You can search on "Excel absolute relative referencing" for much more information.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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