View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.newusers
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Macro to delete rows containing specific data

Sub demo()
s1 = "MTH"
s2 = "TP"
For i = 1000 To 1 Step -1
v = Cells(i, "A").Value
If InStr(v, s1) Or InStr(v, s2) Then
Cells(i, "A").EntireRow.Delete
End If
Next
End Sub

This is coded for column A and 1000 rows, adjust as you require.
--
Gary's Student


"Slohcin" wrote:

I have a spreadsheet with the following data in a column:

C100
C101
MTH1
MTH2
R1
R2
TP1
TP2

I wish to delete all rows that contain MTH or TP in that column.
A macro to do this would be great.
--
Thanks
Slohcin