Reputation: 21764
I want to copy all formulas from one sheet to another using VBA. I don't want to copy anything else than the formulas. What is a good way to do this?
To explain with an example, if the source sheet contains:
formula value value
blank formula value
blank blank formula
and the target sheet contains:
1 2 3
4 5 6
7 8 9
I want the target sheet to get the values:
formula 2 3
4 formula 6
7 8 formula
Upvotes: 0
Views: 2564
Reputation: 96753
How about:
Sub dural()
Dim r As Range, ady As String
For Each r In Sheets("Sheet1").Cells.SpecialCells(xlCellTypeFormulas)
ady = r.Address
r.Copy Sheets("Sheet2").Range(ady)
Next
End Sub
Upvotes: 1