Computing with dates

alonzo3

New Member
Joined
Mar 14, 2002
Messages
2
I am still trying to compute the number of
days between 2 dates. I am able to do so on
a NEW worksheet, but for the life of me, I
can not do so on an EXISTING worksheet. I am
trying to compute the number of days between
the current date minus 1/1/1995. Don't know why I can do it on a NEW work sheet, but not on an EXISTING worksheet. I have tried some of the responses to my original posting to no avail. Thanks Al N.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Private Sub Worksheet_Activate()
'Right click on the sheet tab at the bottom
'and select 'View Code' At the top left
'make sure the dropdown
'says 'Worksheet'
'If not then click on the down arrow and
'select 'Worksheet'
'Copy and paste this exactly as it is shown
'here.
'Replace A1 shown below with the cell
'which you wish to display
'the number of days displaced between now
'and 1/1/1995
'Every time you open this worksheet the
'number will be
'refreshed. There are several other options
'but I prefer
'to use VB code instead of formulas
Dim ShowDaysInThisCell As String
ShowDaysInThisCell = "A1" '<< Replace A1
'if necc. but leave the quotes
ActiveSheet.Range(ShowInThisCell).Value = _
DateDiff("d", #1/1/1995#, Now)
End Sub
 
Upvote 0
Private Sub Worksheet_Activate()
'Right click on the sheet tab at the bottom
'and select 'View Code' At the top left
'make sure the dropdown
'says 'Worksheet'
'If not then click on the down arrow and
'select 'Worksheet'
'Copy and paste this exactly as it is shown
'here.
'Replace A1 shown below with the cell
'which you wish to display
'the number of days displaced between now
'and 1/1/1995
'Every time you open this worksheet the
'number will be
'refreshed. There are several other options
'but I prefer
'to use VB code instead of formulas
Dim ShowDaysInThisCell As String
ShowDaysInThisCell = "A1" '<< Replace A1
'if necc. but leave the quotes
ActiveSheet.Range(ShowInThisCell).Value = _
DateDiff("d", #1/1/1995#, Now)
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,172
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