Code To Subtract Date On Opening

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,748
Office Version
  1. 365
Platform
  1. Windows
I have a workbook that when I open it I would like the date in the column to be taken away from a year every time I open it and give result please.

13/12/2021 00:00​
276 Days
23/09/2021 00:00​
194 Days
11/10/2021 00:00​
213 Days
20/09/2021 00:00​
191 Days
30/07/2021 00:00​
140 Days

So in example above row 1, 13/12/2021 there are 276 days until 13/12/2022. I would like the code to work this out and give the new answer when opened. So if I open file in 2 days time it will automatically say 274 Days and so on....thanks.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
=DAYS(A1,today())
assuming the date is in A1
And will get the date of today and work out the days based on the date in A1 and todays date , when the spreadsheet is opened
Will get value when the date passes the date in A1

Book12
ABC
112/13/21276 Days276
Sheet1
Cell Formulas
RangeFormula
C1C1=DAYS(A1,TODAY())
 
Upvote 0
Thanks that worked them out fine when entered now, I will look again tomorrow see if it changes. Thanks.
 
Upvote 0
One other thing I cant get rid of the 00:00, I have tried text to columns but it remains e.g 13/12/2021 00:00
 
Upvote 0
change the format of the cell
probably set to
DD/MM/YYYY HH:MM
set to
DD/MM/YYYY
 
Upvote 0
=DAYS(A1,today())
assuming the date is in A1
And will get the date of today and work out the days based on the date in A1 and todays date , when the spreadsheet is opened
Will get value when the date passes the date in A1

Book12
ABC
112/13/21276 Days276
Sheet1
Cell Formulas
RangeFormula
C1C1=DAYS(A1,TODAY())
Upon opening I now have #NAME? and the same when I enter the formula again? Also the formula changed to =_xlfn.DAYS(A2,TODAY()) ?
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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