Solved

Set ActiveCell.FormulaR1C1 with variable

Posted on 2010-11-11
2
1,067 Views
Last Modified: 2012-05-10
Is there a way to dynamically reference the row or column utilizing a variable?

Example:

ActiveCell.FormulaR1C1 = "=SUM(R[-19]C:R[-1]C)"

Instead of the [-19], I need the ability to vary the number of rows based on the number of rows currently holding data. I have a variable (integer) "r" that currrently holds the number of the last row with data, so I'd like to be able to substitute "r" for "-19". I have tried it using an integer and also a string, but can't get it to function.
0
Comment
Question by:BryanKipp
2 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 500 total points
ID: 34114210
Did you tryed like this?

ActiveCell.FormulaR1C1 = "=SUM(R[" & r & "]C:R[-1]C)"

0
 

Author Closing Comment

by:BryanKipp
ID: 34114240
That works! Thanks!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now