To automatically delete rows in a searched range I made code below,
Dim firstCAP As Range
Dim lastCAP As Range
firstCAP = ActiveCell.Rows
'goto first cell that is empty
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate
Loop
ActiveCell.Offset(-1, 0).Activate
lastCAP = ActiveCell.Rows
Rows("firstCAP:lastCAP").Select
Selection.Delete Shift:=xlUp
I get Run-time error 91
Object variable or with block variable not set
What did I do wrong?
Bookmarks