Results 1 to 4 of 4

Thread: Solved: DAYS360 function within VB

  1. #1

    Solved: DAYS360 function within VB

    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??

    [VBA]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
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    that works a treat thanks for all your help

    Have a nice day

    Sarah

  4. #4
    VBAX Mentor MaximS's Avatar
    Joined
    Sep 2008
    Location
    Stoke-On-Trent
    Posts
    360
    Location
    try that:

    [VBA]
    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
    [/VBA]

    or:

    [VBA]
    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
    [/VBA]

Posting Permissions

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