Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Fill down Formulas

Posted on 2011-09-06
9
Medium Priority
?
312 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 1000 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 1000 total points
ID: 36489035
Try:

Range("E9:T9").AutoFill Destination:=Range("E9:T" & LR), Type:=xlFillDefault
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Industry Leaders: 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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…

730 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