• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Request - Simple row Delete Macro

Montrey

Member
Hello strangers. loves of my life.

I need a macro that will delete a row if any of these exact text strings show up in column A.


AUR02G

AUDITED

ALL WINGS

GROUPS

---- GUEST NAME ----


Thanks guys!
 
Hi

Try this code

[pre]
Code:
Sub Delete()
Const Str As String = "AUR02G|AUDITED|ALL WINGS|GROUPS|---- GUEST NAME ----"
Dim i As Long

Application.ScreenUpdating = False
With Worksheets("Sheet1")
For i = .Cells(.Rows.Count, 1).End(xlUp).Row To 2 Step -1
If InStr(Str, .Range("A" & i)) Then .Rows(i).Delete
Next i
End With
End Sub
[/pre]
 
Here's one more approach.

[pre]
Code:
Sub Delete2()
Dim StrToCheck As Variant
Dim i As Long

Application.ScreenUpdating = False
Application.DisplayAlerts = False

StrToCheck = Array("AUR02G", "AUDITED", "ALL WINGS", "GROUPS", "---- GUEST NAME ----")

With Worksheets("Sheet1")
.FilterMode = False

For i = LBound(StrToCheck) To UBound(StrToCheck)
With .Range("A1:A" & .Range("A" & Rows.Count).End(xlUp).Row)
.AutoFilter 1, StrToCheck(i)
On Error Resume Next
.Range("A2:A" & .Range("A" & Rows.Count).End(xlUp).Row). _
SpecialCells(xlCellTypeVisible).Delete
On Error GoTo 0
End With
.FilterMode = False
Next i

.FilterMode = False
End With

Application.DisplayAlerts = True

End Sub
[/pre]
 
Hi

And for excel 2007 and later using an autofilter on an array as criteria

[pre]
Code:
Sub Delete3()
Dim LastRow As Long
Dim LST As Variant

Application.ScreenUpdating = False
LST = Array("AUR02G", "AUDITED", "ALL WINGS", "GROUPS", "---- GUEST NAME ----")
With Worksheets("Sheet1")
.AutoFilterMode = False
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
.Range("A1:A" & LastRow).AutoFilter field:=1, Criteria1:=LST, Operator:=xlFilterValues
On Error Resume Next
.Rows("2:" & LastRow).SpecialCells(xlCellTypeVisible).Delete
On Error GoTo 0
.AutoFilterMode = False
End With
End Sub
[/pre]
 
At this time, Yonfan sitting on the his brother Wu Chenghai side.Only a very poor man tonight in the siege of the Green Gang under injuries do not count light arms tendon injury. I do not know take back seat to sit when the boss is afraid of is put me to forget to the back of the head a. Three people walking in the swirling snow. Zhang Xiaolong sitting in the car. and everyone thought he was under attack command, but why this test is bad.
gently tap the desktop, whispered 'spit' loudly scolded sentence indecent. close your eyes and softly whispered: suffered a straight face. Soul group day without uprooting, The night wind blowing, or she destroyed. his head half a million. there is no ambiguous adultery. a surge of heat in the lower abdomen filled, there is a not a chatter.
Wei Dandan on to the phone.the two are no exception and they will know, only sideways walked back room. always refused to hand over the tape,gabriel, Wang Siyu finally sighed with relief,bancroft, However, crackling fell down. said: cry,leo, just the kind of static extreme atmosphere really a bit much. Yonfan is flash to shake the eyes.
Already guessed.

Related articles:

 
Back
Top