PDA

View Full Version : Solved: DAYS360 function within VB



IrishCharm
03-05-2009, 05:08 AM
Hi,

I want to use the Days360 function within VB but am unsure how it works - the below was the closest i came to getting it work.

Any ideas??

Option Explicit
Sub TEST()
Dim str_Date1 As Date
Dim str_Date2 As Date
str_Date1 = "28/03/2008"
str_Date2 = "25/07/2009"
MsgBox Application.WorksheetFunction.Days360(Range(str_Date1), Range(str_Date2))
End Sub

Bob Phillips
03-05-2009, 05:11 AM
Sub TEST()
Dim str_Date1 As Date
Dim str_Date2 As Date
str_Date1 = "28/03/2008"
str_Date2 = "25/07/2009"
MsgBox Application.Days360(DateValue(str_Date1), DateValue(str_Date2))
End Sub

IrishCharm
03-05-2009, 05:14 AM
that works a treat thanks for all your help

Have a nice day

Sarah

MaximS
03-05-2009, 05:14 AM
try that:



Option Explicit
Sub TEST()
Dim str_Date1 As Date
Dim str_Date2 As Date
str_Date1 = "28/03/2008"
str_Date2 = "25/07/2009"
MsgBox Application.WorksheetFunction.Days360(str_Date1, str_Date2)
End Sub


or:



Option Explicit
Sub TEST()
Dim str_Date1 As Date
Dim str_Date2 As Date
str_Date1 = Range("A1").Value
str_Date2 = Range("A2").Value
MsgBox Application.WorksheetFunction.Days360(str_Date1, str_Date2)
End Sub