Hi
I have this macro I wrote which drags down formulas to the last row the formulas are contained in a certain row,
Sub CopyFormula()
Dim LastRow As Long
Dim Row As Long
Dim Ans As Long
Dim ColNo As Long
LastRow = Sheet2.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Ans = MsgBox("Continue?", vbYesNo + vbQuestion, "Tell Me")
If Ans = vbNo Then Exit Sub
ColNo = 2
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
ColNo = 3
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
End Sub
However I want to condense the part below to that I can state drag down columns D:E so to speak:
ColNo = 2
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
ColNo = 3
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
So it looks like this:
ColNo = 2:3
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
However when Ive tried to do this I get errors.
Thanks
I have this macro I wrote which drags down formulas to the last row the formulas are contained in a certain row,
Sub CopyFormula()
Dim LastRow As Long
Dim Row As Long
Dim Ans As Long
Dim ColNo As Long
LastRow = Sheet2.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Ans = MsgBox("Continue?", vbYesNo + vbQuestion, "Tell Me")
If Ans = vbNo Then Exit Sub
ColNo = 2
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
ColNo = 3
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
End Sub
However I want to condense the part below to that I can state drag down columns D:E so to speak:
ColNo = 2
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
ColNo = 3
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
So it looks like this:
ColNo = 2:3
Sheet2.Cells(1, ColNo).Select
Selection.Copy
Range(Cells(2, ColNo), Cells(LastRow, ColNo)).Select
ActiveSheet.Paste
However when Ive tried to do this I get errors.
Thanks
Last edited: