Thanks for the suggestions guys. Couldn't work out the clipboard methods. Tried DestinationRange.Formula = FormulaRange.Formula instead of the With block. Also removed .Value = .Value from inside the With block. Both produce the same result. The values (not the formulas) from 'FormulaRange' are entered into the 'DestinationRange'.
EDIT: This next paragraph is wrong (I've now discovered, see later posts). Range.Formula DOES work when copy and pasting multiple formulas in a range but the formulas are not relative. This method essentially copies and pastes the formulas as strings.
I've done my own testing and discovered that this method (Range.Formula) works only when copying a single formula to a range (single-to-single, single-to-multiple cells). It cannot be used to copy multiple formulas at the one time. A working alternative (I just thought of now, of course) is paste columns, rather than rows, which works fine because each column contains the same formula. Range.Formula method works well in this code:
Dim LastRow As Integer
LastRow = Range("L1").Value
For c = 1 To 674
Dim TopCell As Range
Set TopCell = Cells(4, c)
Dim ColumnRange As Range
Set ColumnRange = Range(Cells(5, c), Cells(LastRow, c))
ColumnRange.Formula = TopCell.Formula
ColumnRange.Copy
ColumnRange.PasteSpecial xlPasteValues
Next c
I have columns that depend on different columns in different positions, so I was stuck with going down the rows. I've managed to eliminate the "selections" to come up with this, which is the best I can do I think:
Sub CopyPasteDown()
Application.ScreenUpdating = False
Dim r As Integer
For r = Range("J1") To Range("L1")
Dim DestinationRange As Range
Set DestinationRange = Range(Cells(r, 1), Cells(r, 674))
Dim FormulaRange As Range
Set FormulaRange = Range("A4:YY4")
Dim FirstCell As Range
Set FirstCell = Cells(r, 1)
FormulaRange.Copy
FirstCell.PasteSpecial xlPasteFormulasAndNumberFormats
DestinationRange.Copy
DestinationRange.PasteSpecial Paste:=xlPasteValues
Next r
Application.ScreenUpdating = True
End Sub
Thanks so much for the help.
Cheers, Rob
Bookmarks