Application.WorkSheetFunction.DafeDif (not DateDiff)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Am I doing this wrong? Or, can I not call DateDif from vb? I don't want to use datediff because it doesn't give real time. Ie: the months start on the first, not on the day of month chosen. Is there a better way w/o having to open a worksheet to get the data

Sub AccFreeTime(
Dim AccDayTime As Dat
Dim Result As Varian
Result = Application.WorksheetFunction.DateDif(AccDayTime, NOW(), "ym"
MsgBox (Result
End Su

Thanks in advance for any/all assistance.
 
Rick,

You can't use the DATEDIF worksheet function in VBA.


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

Rick said:
Am I doing this wrong? Or, can I not call DateDif from vb? I
don't want to use datediff because it doesn't give real time.
Ie: the months start on the first, not on the day of month
chosen. Is there a better way w/o having to open a worksheet to
get the data?
 
Am I doing this wrong? Or, can I not call DateDif from vb? I don't want to use datediff because it doesn't give real time. Ie: the months start on the first, not on the day of month chosen. Is there a better way w/o having to open a worksheet to get the data?

Sub AccFreeTime()
Dim AccDayTime As Date
Dim Result As Variant
Result = Application.WorksheetFunction.DateDif(AccDayTime, NOW(), "ym")
MsgBox (Result)
End Sub

Thanks in advance for any/all assistance.

Datedif is not in the list of worksheet functions available to VBA, so you
can't use it here.

You would probably have to write a routine that would do exactly what you want.


--ron
 
Back
Top