Closed Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    07-03-2009
    Location
    NYC, USA
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    2

    Running XIRR in Excel via a User Defined Function

    I created a user defined function called FilterXIRRNew in Excel 2003 that takes in a bunch of arrays, does some processing and filtering and finally calls the built in XIRR function in excel to calculate the IRR for a series of cash flows. The function worked fine in Excel 2003

    Code:
    Public Function FilterXIRRNew(FilteredCF, FilteredDates, FilteredVal, valDate, InvestMultiple)
        
    ' Bunch of code here followed by calling the XIRR function
    
                FilterXIRRNew = Application.Run("xIRR", TrueCF, TrueDates, GuessIRR)
    
    
    End Function
    This function worked fine in Excel 2003. Now that I have opened the file in 2007, FilterXIRRNew is no longer working properly. The code works fine upto the line where it calls the in built XIRR function. I have enabled Macros in Excel 2007 and also installed the Add-In that contains the built-in XIRR function. The XIRR function works properly byitself. I am only having trouble with my user defined FilterXIRR function.

    Any help would be very much appreciated.
    Thanks.

  2. #2
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,126

    Re: Running XIRR in Excel via a User Defined Function

    Can you use the XIRR function successfully as a UDF in the 2007 add-in?

    Try
    Code:
    FilterXIRRNew = myAddIn!xIRR(TrueCF, TrueDates, GuessIRR)
    Please read the forum rules before posting again.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    01-21-2010
    Location
    India, Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    1

    Cool Re: how to I use XIRR to calculate returns for selected stocks in my portfolio

    Using XIRR for the a series of all stocks is pretty straightforward when you have recorded all transactions in terms of cashflows with their respective dates.

    But if I want to calculate returns for exixting stocks within that portfolio, then I need to match and pass arguments to the xirr function only for those specific assets.

    Something like SUMIF, but unfortunately there is no XIRR if.

    How do I get this done. Its been driving me nuts. I guess there is a way to write a macro or VBA function to pass arguments of that specific stock (and sorted in the ascending order of dates as XIRR needs) to the XIRR function.

    But I dont know much of macros or VBA to do this.!!!...pls help

  4. #4
    Forum Guru rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Running XIRR in Excel via a User Defined Function

    pinnacle,

    Please start your own new thread! and refer to this one if necessary.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  5. #5
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,033

    Re: Running XIRR in Excel via a User Defined Function

    Hi pinnacle,

    welcome to the forum. As rwgrietveld points out ...

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon below the post.

    Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0