Inserting a Range Into A Formula Using a Variable

username142

New Member
Joined
May 30, 2014
Messages
23
I've declared the variable 'Action' as a string, and I am assigning a range to it based upon the contents of a cell. For example, the first one being assigned is C52:CY55. And I'm trying to insert that range into the formula below using the variable name, but it's not working. In the formula that's inserted to the active cell, the range is posting as $AZ:$AZ:'CY55' instead. Does anyone have any suggestions?

Code:
ActiveCell.Formula = _
            "=SUM(INDEX('" & CurrentSheet & "'!" & Action & ",,COLUMN()+Summary!RC[-1]-2))"
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try inserting 'Action.Address' instead of just 'Action' The Excel formula is looking for a cell reference, not a variabele value.
 
Upvote 0
You can't mix A1 and R1C1 notation.

This part of your formula uses R1C1

Summary!RC[-1]-2

and in your post you appear to be saying Action is a string variable with a range reference in A1 notation.
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,038
Latest member
apwr

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