macro

P

Pascale

I am very new at macros. I would to create one that would after sorting a
table delete automatically the whole row if a specific cell from that row
contain a specific value. For example if I sort my table by column C: who is
enrolled, waiting for enrolment, pass to centre, rejected by centre. I want
then my macro to select all the "rejected by centre" and delete these rows.
Is it possible?
Many thanks
 
D

Don Guillett

You can do this without sorting by a looping macro such as
sub deletebadrows()
for i=cells(rows.count,"a").end(xlup).row to 2 step -1
if ucase(cells(i,"c"))="REJECTED BY CENTRE" then rows(i).delete
next i

or if you sort and the bad rows are at the bottom use FIND and delete all
rows below.
Other ways.
 
G

Gord Dibben

Sub delete_rows()
Dim c As Range
With Columns("C")
Do
Set c = .Find("rejected by centre", LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False)
If c Is Nothing Then Exit Do
c.EntireRow.Delete
Loop
End With
End Sub


Gord Dibben MS Excel MVP
 
Top