DELETE ROWS FROM XLS IF THE ROW CONTAINS THE STRING

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)
 
D

Don Guillett

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top