Solved

copy formulas down

Posted on 2013-05-21
2
248 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
[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
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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 how to use longer labels with horizontal bar charts instead of the vertical column chart.

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