Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2008

    Unanswered: macro with varying range of cells

    How do I create a macro that takes the selected range and allows me to use that range in a formula?

    Here's what I want to do:
    Allow the user to select a range of cells, say Q6:Q8.
    Then put this formula in cell R6.... =XIRR(Q6:Q8, P6:P8)

    Is it possible?

  2. #2
    Join Date
    Mar 2008
    I just started VBA today, but from what I know so far, I would guess
    you could write it similar to this:

    'The Selection has already been made by the user when the macro is run, so:

    Dim i as Long, j as Long
    For i=1 to Selection.rows.count Step 1
      For j=1 to Selection.columns.count Step 1
        'DoStuff like  msgbox Selection.Cells(i,j).Value
      Next j
    Next i
    I haven't tried it, it's just a quick shot to give an idea.
    "My brain is just no good at being a relational Database - my relations suck real bad!"

Posting Permissions

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