Solved

copy formulas down

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

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

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,…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

630 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