Solved

Auto fill with range in variable in excel macro

Posted on 2007-03-23
3
878 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:vdixon79
3 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 50 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

813 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

13 Experts available now in Live!

Get 1:1 Help Now