DELETE ROWS FROM XLS IF THE ROW CONTAINS THE STRING

  • Thread starter Thread starter sunilsk1
  • Start date Start date
S

sunilsk1

Hi
I wanted a macro , Which would find a particular string in that row and
then delete that row.
for example in the following example i want to delete all the Rows
which contain the String "aaa","syz"......( I have about 500 words).

aaa 1 jan
bbb 2 feb
aaa 3 mar
bbb 4 apr
aaaaa 5 may
syz 6 jun
xan 7 jul
kjhf 8 aug
aaa 4 feb
I'll be happy if i get this in a VB application ,
Like the Application should browse for the XLS , then delete those Rows
and give the final output as the XLS with deleted Rows( which had those
strings)
 
Sub deleterowif()
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row '12
Select Case LCase(Cells(i, 1))
'Case "x", "s": MsgBox Cells(i, 1).Address'for testing
Case "x", "s": Rows(i).Delete
End Select
Next
End Sub
 
Back
Top