+ Reply to Thread
Results 1 to 3 of 3

XIRR - naming ranges to include monthly cash flows only

  1. #1
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    273

    XIRR - naming ranges to include monthly cash flows only

    Ok I wrote a macro that gave me a range to feed the IRR function (variables are for other IRRs I need to add later) but the last line didn't work Range("E180").Formula = "=XIRR(" & str & ")", the str is ok though, can someone please help me fix it?

    PHP Code: 
    Sub CalculateIrrs()
    Dim c As Range
    Dim cRow 
    As Integerstartcol As Integerlastcol As Integer
    Dim rng1 
    As Range
    Dim strSearch 
    As String
       Dim Cell 
    As Range
       Dim i 
    As IntegerAs Integer
       Dim str 
    As Stringaddi As String
       Dim Columnnumber1
    Columnnumber2
       Dim ColumnLetter1 
    As StringColumnLetter2 As String
       Worksheets
    ("Model").Activate
       startcol 
    6
       lastcol 
    Worksheets("Model").Cells(6Columns.Count).End(xlToLeft).Column
         strSearch 
    "UL PT Net Flows - Unlevered Pre-Tax"
        
    Set rng1 Range("B:B").Find(strSearch, , xlValuesxlWhole)
        
    rng1.Select
       Set c 
    ActiveCell
       cRow 
    c.Row
      Columnnumber1 
    startcol
      j 
    Worksheets("Inputs").Range("ModelLastYear").Value Worksheets("Inputs").Range("ModelFirstYear").Value 1
     
    For 1 To j
     
    'MsgBox i
       Columnnumber2 = Columnnumber1 + 11
     ColumnLetter1 = Split(Cells(1, Columnnumber1).Address, "$")(1)
     '
    MsgBox ColumnLetter1
     ColumnLetter2 
    Split(Cells(1Columnnumber2).Address"$")(1)
        
    'MsgBox ColumnLetter2
     addi = ColumnLetter1 & cRow & ":" & ColumnLetter2 & cRow
    str = str & "," & addi

    Columnnumber1 = Columnnumber2 + 2
    Next
    str = Right$(str, (Len(str) - Len(",")))
    MsgBox str
    Range("E180").Formula = "=XIRR(" & str & ")"
     End Sub 
    thanks!
    Last edited by lynnsong986; 01-17-2020 at 02:54 PM.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: XIRR - naming ranges to include monthly cash flows only

    "XIRR(values, dates,[guess])" function must have an area/array with data, not a string - upload a reliable xls example of data, but not too large.

    Ps.: Do not use 'str' as a variable/constant name, it is the name of the vba function.

  3. #3
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    273

    Re: XIRR - naming ranges to include monthly cash flows only

    Thanks very much for replying. Ace_XL provided me with a very nice formula that does what I need. Here is the link - I also posted it in the formula section as the problem is more about the formula.

    https://www.excelforum.com/excel-for...ml#post5262297

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. XIRR formula not working when adding extra cash flows
    By lp12345 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-27-2018, 02:23 AM
  2. NPV/XNPV for monthly cash flows
    By cc918 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-23-2018, 06:03 PM
  3. Replies: 5
    Last Post: 07-09-2017, 03:24 AM
  4. Monthly to Quarterly Cash Flows
    By realvirtuality1 in forum Excel General
    Replies: 2
    Last Post: 06-24-2015, 02:32 PM
  5. [SOLVED] uncertain cash-flows timing. create monthly cash report
    By excobra in forum Excel General
    Replies: 3
    Last Post: 05-14-2014, 11:10 AM
  6. XIRR: Different cash flows but same answer. Why?
    By Guy Hoffman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-24-2007, 11:37 AM
  7. IRR formula for monthly cash flows
    By MB Burgis in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-11-2006, 11:10 PM

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.6.0 RC 1