Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Auto fill with range in variable in excel macro

Posted on 2007-03-23
3
Medium Priority
?
914 Views
Last Modified: 2008-02-26
Hi

I would like to copy some formula using variable which contain row number (the most to fill in)

I did something like this:

    ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
    Selection.AutoFill Destination:=Range("A1:A" & Range("NrR").Value)

In NrR (integer) I store say no. 10
And now using auto fill I would like to copy formula 10 rows down. How to change my macro code?

Regards

Tomasz
0
Comment
Question by:E J Pope
1 Comment
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 200 total points
ID: 18780887
Just assign the formula to all cells at once:

   Range("C1").Resize(Range("NrR").Value).FormulaR1C1 = "=RC[-1]/RC[-2]"

Kevin
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

810 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