Macro to copy range of formulas to equal data lines

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to have a macro to copy a range of formulas in row 2 down for
all lines of input in an adjacent range. For example:

Input Formula
Row 2 Cell X2 Cell Y2
Row 3
Row 4
Row 5

In input date in the range Row2 through Row 5. I want to copy the formulas
in Cells X2 and Y2 down for the other three lines of input.

Thanks for any help that you can provide.
 
Hmmm. What column gets the dates?

Option Explicit
Sub testme01()

Dim LastRow As Long
Dim FirstRow As Long

With ActiveSheet
FirstRow = 2 'headers in row 1?
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row 'I used column A.

.Range(.Cells(FirstRow, "C"), .Cells(LastRow, "C")).FormulaR1C1 _
= .Cells(FirstRow, "C").FormulaR1C1

.Range(.Cells(FirstRow, "d"), .Cells(LastRow, "d")).FormulaR1C1 _
= .Cells(FirstRow, "d").FormulaR1C1

End With

End Sub
 
Dave,

This worked great.

Thanks.

Lori

Dave Peterson said:
Hmmm. What column gets the dates?

Option Explicit
Sub testme01()

Dim LastRow As Long
Dim FirstRow As Long

With ActiveSheet
FirstRow = 2 'headers in row 1?
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row 'I used column A.

.Range(.Cells(FirstRow, "C"), .Cells(LastRow, "C")).FormulaR1C1 _
= .Cells(FirstRow, "C").FormulaR1C1

.Range(.Cells(FirstRow, "d"), .Cells(LastRow, "d")).FormulaR1C1 _
= .Cells(FirstRow, "d").FormulaR1C1

End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top