Solved

copy formulas down

Posted on 2013-05-21
2
238 Views
Last Modified: 2013-05-21
I am using a macro that copies a formula down.  The change I need is that in any column between A and Az where the first row has a formula I want to copy it down and if it does not have a formula then do nothing.

Thanks,
Montrof

Sub FormulaFill()
    Application.ScreenUpdating = False

    LastRow = range("A" & Rows.Count).End(xlUp).Row
    range("Q2").Copy Destination:=range("Q3:Q" & LastRow)
    range("A1").Select

    Application.ScreenUpdating = True

End Sub

Open in new window

0
Comment
Question by:montrof
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39185359
Here is a macro to fill the formulas down:
Sub FormulaFill()
    Dim cel As Range, rg As Range
    Dim lastrow As Long
    lastrow = Range("A" & Rows.Count).End(xlUp).Row
    If lastrow < 2 Then Exit Sub
    
    Application.ScreenUpdating = False
    
    Set rg = Range("A2:AZ" & lastrow)
    For Each cel In rg.Rows(1).Cells
        If cel.HasFormula Then
            cel.Copy
            Intersect(cel.EntireColumn, rg).PasteSpecial xlPasteFormulas
        End If
    Next
    Range("A1").Select

End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:montrof
ID: 39185425
Thank you very much
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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…

820 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