If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > macro with varying range of cells

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-09, 16:24
jillen04 jillen04 is offline
Registered User
 
Join Date: Jun 2008
Posts: 47
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?
TIA,
Joanne
Reply With Quote
  #2 (permalink)  
Old 01-20-09, 15:55
freeBatjko freeBatjko is offline
Registered User
 
Join Date: Mar 2008
Posts: 89
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:

Code:
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!"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On