Results 1 to 2 of 2
  1. #1
    ENOBYZARC is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Sep 2014
    Posts
    1

    XIRR in vba

    Hola, I am trying to use XIRR function en Access vba but i received an 1004 error, this is my function. What can go wrong?

    Public Function dblXIRR() As Double


    Dim objExcel As Object
    Dim strValues() As String
    Dim varDates(2) As Variant


    Set objExcel = CreateObject("Excel.Application")


    strValues = Split("1000,500,-2500", ",")


    varDates(0) = CDate("01/01/2010")
    varDates(1) = CDate("01/06/2010")
    varDates(2) = CDate("31/12/2010")


    dblXIRR = objExcel.WorksheetFunction.XIRR(strValues, varDates)


    End Function

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If I recall correctly, you need to set the size of the string array at time of dimension
    Dim strValues(2) As String

    Also, for Access, the Variant type will handle an array. So....
    Dim varDates As Variant

    and (maybe - just air code here)
    varDates = (CDate("01/01/2010"), CDate("01/06/2010"), CDate("31/12/2010"))


Please reply to this thread with any new information or opinions.

Similar Threads

  1. XIRR Function
    By ripcure in forum Reports
    Replies: 3
    Last Post: 05-23-2011, 09:44 AM
  2. XIRR Calculation
    By kathy62959 in forum Programming
    Replies: 0
    Last Post: 12-08-2009, 01:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums