View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Macro code for deleteing rows

Sub delete_sme_rows()

Dim r As Range, j As Long

Set r = ActiveSheet.UsedRange
j = r.Rows.Count + r.Row
Set rdel = Cells(j, "A")
For i = 1 To j - 1
If Cells(i, "C").Value = "SME" Then
Set rdel = Union(rdel, Cells(i, "A"))
End If
Next

rdel.EntireRow.Delete

End Sub

Looks in column C
--
Gary's Student


"DeanT" wrote:

I have the below sheet and wish to write macro to delete entire rows that
contain "SME" in category column. The size of sheet will vary as will the
location of the rows within the sheet. I'm guessing I need a relative macro,
but I can't come up with one that works.

A B Category D
xxx xxx PM y
xgy xxx SME z
sss xxx PM y
ccc nnn SME d

Thanks for your help.

dean