rickbisselink
Board Regular
- Joined
- Oct 16, 2007
- Messages
- 146
L.S.,
I am trying to populate column P with a formula that exists in cell P5. The number of rows is variable and is dependent on the number of rows in column A. As column P is pre-populated, it might be longer or shorter than column A before running the code. It should end up with the same length as column A. I repeat this for several sheets.
I get a runtime error 1004 (method range of object _worksheet failed) in the 7th line below. Can anybody help me out?
Thanks,
Rick
I am trying to populate column P with a formula that exists in cell P5. The number of rows is variable and is dependent on the number of rows in column A. As column P is pre-populated, it might be longer or shorter than column A before running the code. It should end up with the same length as column A. I repeat this for several sheets.
I get a runtime error 1004 (method range of object _worksheet failed) in the 7th line below. Can anybody help me out?
Thanks,
Rick
Code:
With wsActual
LastRowA = .Cells(.Rows.Count, "A").End(xlUp).Row
LastRowP = .Cells(.Rows.Count, "P").End(xlUp).Row
.Range("P5:P" & LastRowA).FillDown
If LastRowP > LastRowA Then
LastRowA = LastRowA + 1
.Range(Cells(LastRowA, 16), Cells(LastRowP, 16)).ClearContents
End If
End With