Delete Row based off cell content

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My spreadsheet has over 1000 lines of data. I'm exporting daily so the
information changes and I do not append to the previous day's data. Because
of the way this report exports out of the host system (which I can't change),
at random rows, a cell in a random column is populated with the words "System
generated". I'm running a series of macros to clean up this spreadsheet
before I import to Access. I need a code that will delete the entire row
when this specfic word appears anywhere in the spreadsheet. I've tried
recording a macro using the filter, but this doesn't seem to work since the
data changes daily. Please help!
Chuck
 
This sample only looks at the first 100 rows, you can adapt it for your needs:


Sub macdel()
Dim L As Long
For L = 100 To 1 Step -1
If Application.CountIf(Rows(L), "System generated") >= 1 Then
Rows(L).EntireRow.Delete
End If
Next
End Sub


The sample code also assumes that System generated is by itself in a cell.
 
Back
Top