Solved

Fill down Formulas

Posted on 2011-09-06
9
304 Views
Last Modified: 2012-05-12
I'm trying to automatically fill down my formulas in a macro but it doesn't seem to be working.

My values start in row B9 and don't always go down to a certain row # so I want to be able to copy down the formulas in columns E9:T9 until it finds no more data in column B.

What's wrong with my code?
Dim LR As Integer
     LR = Range("B9" & Rows.Count).End(xlUp).Row
     Range("E9").AutoFill Destination:=Range("E9:T" & LR), Type:=xlFillDefault

Open in new window

0
Comment
Question by:Lawrence Salvucci
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 250 total points
ID: 36488809
Declare LR as Long in line 1, and in line 2 remove the '9'.
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 36488956
Nope still not working. I'm now getting a "AutoFill method of Range class failed".
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 250 total points
ID: 36489035
Try:

Range("E9:T9").AutoFill Destination:=Range("E9:T" & LR), Type:=xlFillDefault
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 36489155
Still not working. Now it's deleting all my formulas in row E9:T9 and not copying anything down.
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 36489173
Does it matter that my headers are in row 8 with nothing in rows 1:7?
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 36489245
Can you step through the code and check the value of LR? It sounds like you don't have any data.
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 36489277
Code should be:

Dim LR As Long
     LR = Range("B" & Rows.Count).End(xlUp).Row
     Range("E9:T9").AutoFill Destination:=Range("E9:T" & LR), Type:=xlFillDefault

Open in new window


note that I removed the 9 from line 2.
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 36489282
The code also assumes you have data in column B for all the applicable rows.
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 36489302
Got it working. I was running the code before I had any data in column B. Working fine now. Thank you both for your help!
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

739 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