populating cell addresses in formulas

lharris

New Member
Joined
Sep 9, 2002
Messages
12
I need to return a range of cell addresses in a formula but it won't let me append to the formula. If I type activecell.formula = "=IRR(" even that will give me an application or object defined run time error.

Help! I need to be able to populate a cell address range to a formula.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Like this:

Code:
ActiveCell.Formula = "=IRR(A1:A5)"

or if you have a Range object variable, like this:

Code:
Dim Rng As Range
Set Rng = Range("A1:A5")
ActiveCell.Formula = "=IRR(" & Rng.Address(False, False) & ")"
 
Upvote 0
On 2002-09-11 08:55, Andrew Poulsom wrote:
Like this:

Code:
ActiveCell.Formula = "=IRR(A1:A5)"

or if you have a Range object variable, like this:

Code:
Dim Rng As Range
Set Rng = Range("A1:A5")
ActiveCell.Formula = "=IRR(" & Rng.Address(False, False) & ")"

Wonderful! I'm so close, thanks:

Here's the code I'm using for the variant and it doesn't give me errors but it doesn't pull what I want it to (a1 through the end of the populated cells) It pulls 20 cells down from that address for some reason. Any ideas?

Dim Reference As Range
Set Reference = ActiveCell.Range("a1", ActiveSheet.Range("a65536").End(xlUp))
ActiveCell.Formula = "=IRR(" & Reference.Address(False, False) & ")"
 
Upvote 0
Try:

Code:
Set Reference = Range("A1:A" & Range("A65536").End(xlUp).Row)

This selects all the used cells in column A.

Not sure why you are using ActiveCell. If the active cell is B5 then:

Code:
ActiveCell.Range("A1").Select

selects cell B5. In other words the range is relative to the active cell.
 
Upvote 0

Forum statistics

Threads
1,225,071
Messages
6,182,685
Members
453,132
Latest member
nsnodgrass73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top