PDA

View Full Version : clearing data using range(cells)



philfer
02-22-2018, 08:31 AM
Hi,

I'm no sure what is wrong with the below but I keep getting a 1004 error

With Worksheets("Inventory Extract")
lastrow = .Range("A" & .Rows.Count).End(xlUp).Row
lastcol = .Cells(1, .Columns.Count).End(xlToLeft).Column
.Range(Cells(2, 1), Cells(lastrow, lastcol)).Clear
End With

the lastrow and lastcol work and have values of 1106 and 42 but the next line gives the error

Thanks
Phl

Paul_Hossler
02-22-2018, 09:17 AM
Try no dot on the Range, but a dot on the two Cells




Range(.Cells(2, 1), .Cells(lastrow, lastcol)).Clear