Solved

Auto fill with range in variable in excel macro

Posted on 2007-03-23
3
869 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

759 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

19 Experts available now in Live!

Get 1:1 Help Now