C
Chris
I have this following macro which I want to scan through all cells in
my worksheet and delete all rows that don't contain the keywords
"NAME:" and that don't contain the keywords "SUBJ:" I keep getting an
error on "test = Application.Range(r,c).Text" It says "method Range of
object _Application failed" Does anyone know how to get the text from
each cell and compare it to the strings I have? Thanks
Sub DeleteR()
Dim bool As Boolean
For r = Application.Rows.Count To 1 Step -1
bool = False
For c = Application.Columns.Count To 1 Step -1
Dim test As String
test = Application.Range(r, c).Text
If test = "NAME:" Then
'mark bool as true (we found a table name row)
bool = True
End If
If test = "SUBJ:" Then
'mark bool as true (we found a subject area row)
bool = True
End If
Next c
If bool = False Then
'Delete entire row
Application.Rows(r).EntireRow.Delete
End If
Next r
End Sub
my worksheet and delete all rows that don't contain the keywords
"NAME:" and that don't contain the keywords "SUBJ:" I keep getting an
error on "test = Application.Range(r,c).Text" It says "method Range of
object _Application failed" Does anyone know how to get the text from
each cell and compare it to the strings I have? Thanks
Sub DeleteR()
Dim bool As Boolean
For r = Application.Rows.Count To 1 Step -1
bool = False
For c = Application.Columns.Count To 1 Step -1
Dim test As String
test = Application.Range(r, c).Text
If test = "NAME:" Then
'mark bool as true (we found a table name row)
bool = True
End If
If test = "SUBJ:" Then
'mark bool as true (we found a subject area row)
bool = True
End If
Next c
If bool = False Then
'Delete entire row
Application.Rows(r).EntireRow.Delete
End If
Next r
End Sub