Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Computing with dates

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  2. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    What are you getting as an answer on an existing worksheet?

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  4. #4
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •