+ Reply to Thread
Results 1 to 4 of 4

to find number of days between 2 dates using vba code in excel

  1. #1
    Registered User
    Join Date
    10-29-2005
    Posts
    12

    Unhappy to find number of days between 2 dates using vba code in excel

    Hi All,

    i have 2 DateTime Pickers and a textbox.
    This texbox should contain the number of days between these 2 dates.

    I am unable to calculate number of days between 2 dates.

    I have used DateDIf function in the VBA code

    when i run the program i get "Compile error: Sub or Function not defined"

    Please help me to solve this problem.
    1. why i get this "Sub or function not defined error"
    2. What to do to solve these kind of problem
    3. Please help to calculate the number of days between given 2 dates

  2. #2
    Rowan Drummond
    Guest

    Re: to find number of days between 2 dates using vba code in excel

    If you want the number of days between two dates just subtract one from
    the other:

    Private Sub DTPicker2_Change()
    Dim sDate As Date
    Dim eDate As Date
    sDate = Me.DTPicker1.Value
    eDate = Me.DTPicker2.Value
    Me.TextBox1 = eDate - sDate
    End Sub

    Hope this helps
    Rowan

    sjayar wrote:
    > Hi All,
    >
    > i have 2 DateTime Pickers and a textbox.
    > This texbox should contain the number of days between these 2 dates.
    >
    > I am unable to calculate number of days between 2 dates.
    >
    > I have used DateDIf function in the VBA code
    >
    > when i run the program i get "Compile error: Sub or Function not
    > defined"
    >
    > *Please help me to solve this problem.
    > 1. why i get this "Sub or function not defined error"
    > 2. What to do to solve these kind of problem
    > 3. Please help to calculate the number of days between given 2 dates*
    >
    >


  3. #3
    Registered User
    Join Date
    10-29-2005
    Posts
    12

    Smile

    hi ,
    thanks rowan for ur help.
    ur suggestion worked

  4. #4
    Rowan Drummond
    Guest

    Re: to find number of days between 2 dates using vba code in excel

    You're welcome.

    sjayar wrote:
    > hi ,
    > thanks rowan for ur help.
    > ur suggestion worked
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1