Solved

copy formulas down

Posted on 2013-05-21
2
209 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 80

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Using EXCEL to count the number of Rows 4 46
TT Column Arrange 10 28
Convert .PDF 6 43
Top 10 with duplicates in Excel Table 4 13
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now