G
Guest
I have the following code. The purpose is to search the first column for a
predetermined value. If the value is found delete the first 7 columns of the
row and shift everything up.
The code works but does not completely delete everything. It will only
delete a few of the matches leaving the rest. The table in the sheet can
have from a few hundred entries to almost 20,000. Can anyone give me a fix
that will delete all the matches?
Thanks
' This code searchs the sheet for matching variables.
' If found it sets the range to delete and then deletes them shifting up
Do While xlSheet.Cells(Row, 1).Value <> ""
If xlSheet.Cells(Row, 1).Value = "2007-05" Then
Set BegRange = xlSheet.Cells(Row, 1)
Set EndRange = xlSheet.Cells(Row, 7)
xlSheet.Cells.Range(BegRange, EndRange).Delete (xlUp)
End If
Row = Row + 1
Loop
predetermined value. If the value is found delete the first 7 columns of the
row and shift everything up.
The code works but does not completely delete everything. It will only
delete a few of the matches leaving the rest. The table in the sheet can
have from a few hundred entries to almost 20,000. Can anyone give me a fix
that will delete all the matches?
Thanks
' This code searchs the sheet for matching variables.
' If found it sets the range to delete and then deletes them shifting up
Do While xlSheet.Cells(Row, 1).Value <> ""
If xlSheet.Cells(Row, 1).Value = "2007-05" Then
Set BegRange = xlSheet.Cells(Row, 1)
Set EndRange = xlSheet.Cells(Row, 7)
xlSheet.Cells.Range(BegRange, EndRange).Delete (xlUp)
End If
Row = Row + 1
Loop