How to display "#N/A" error if the date value in a cell is greater than TODAY()?

Mr. Snrub

Board Regular
Joined
May 22, 2005
Messages
150
Office Version
  1. 365
Platform
  1. Windows
I have the following formula in a table column that prints a sequence of dates starting at 3/21/2018:

Excel Formula:
=IF(ROW()-ROW(Table1[#Headers])=1,DATE(2018,3,21),OFFSET([@Date],-1,0)+1)


I just want to add to that formula "if the current date to be displayed will be greater than today, then display the N/A error." How do I do that? The closest I can come up with is to duplicate the entire if statement in the "value if false" section of the outer if statement, like this:

Excel Formula:
=IF(IF(ROW()-ROW(Table1[#Headers])=1,DATE(2018,3,21),OFFSET([@Date],-1,0)+1)>TODAY(),NA(),IF(ROW()-ROW(Table1[#Headers])=1,DATE(2018,3,21),OFFSET([@Date],-1,0)+1))

...but that seems needlessly complex. Is there a simpler way to do this?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
For a start, I would be trying to avoid the volatile function OFFSET.

What about this in the first cell of your data column?

Excel Formula:
=LET(d,DATE(2018,3,21)+ROW()-ROW(Table1[#Headers])-1,IF(d>TODAY(),NA(),d))
 
Upvote 0
Solution
Thank you, that worked great.

I see now that OFFSET() isn't needed here, since the cell values of one cell are not dependent on the cell directly above, the value can be derived from the row number of the current cell and the starting value. But other times OFFSET() is unavoidable, like so:

 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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