Solved

Fill down Formulas

Posted on 2011-09-06
9
307 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

617 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