M
mikeburg
When I import a report & run the following VBA code to delete the
headings, after the last heading is deleted, I get:
Runtime Error '91": Object Variable or With block variable not
set
What VBA code should be used to terminate the loop to prevent the
error?
mikeburg
Sub CDeleteHeadings()
Cells.find(what:="Name & Address", After:=ActiveCell,
LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Do
ActiveCell.Offset(rowoffset:=0).EntireRow.Delete
ActiveCell.Offset(rowoffset:=0).EntireRow.Delete
Cells.findnext(After:=ActiveCell).Activate
Loop Until Cells.findnext = False
headings, after the last heading is deleted, I get:
Runtime Error '91": Object Variable or With block variable not
set
What VBA code should be used to terminate the loop to prevent the
error?
mikeburg
Sub CDeleteHeadings()
Cells.find(what:="Name & Address", After:=ActiveCell,
LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Do
ActiveCell.Offset(rowoffset:=0).EntireRow.Delete
ActiveCell.Offset(rowoffset:=0).EntireRow.Delete
Cells.findnext(After:=ActiveCell).Activate
Loop Until Cells.findnext = False