View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default number of days between dates

You can just subtract the earlier date from the later date to get
the number of days. E.g.,
vNumberOfDays = vDate2-vDate1


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"JT" wrote in message
...
I need to calculate the number of days between dates but
am not having much luck with the datediff function.
Here's the code I'm trying to use:

Dim vNumberofDays As Integer
Dim vDate1 As Date
Dim vDate2 As Date

Range("A1").Select
ActiveCell.Offset(1, 25).Select

Do Until IsEmpty(ActiveCell.Offset(0, -3)) = True
vDate1 = ActiveCell.Offset(0, -16)
vDate2 = ActiveCell.Offset(0, -9)
vNumberofDays = DateDiff(d, vDate1, vDate2)
ActiveCell = vNumberofDays
vNumberofDays = 0
ActiveCell.Offset(1, 0).Select
Loop

Any help would be appreciated.....Thanks