VBA macro: Delete Rows based on different Criterias

csl6989

New Member
Joined
Jan 2, 2014
Messages
3
Hi all,

First and foremost happy holidays and thank you</SPAN></SPAN> for any help provided. I have copied a code from internet and I would like to modify it but dont know how ?

In the code below: it deletes the entire row rows based on the criteria different "RVWD" .

I would to modify it so deleted Rows different "RVWD","NEW","APRV".



Dim bUnion As Boolean
Dim i As Long, lastrow As Long
Dim r1 As Range
Dim v1 As Variant

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
v1 = ActiveSheet.Range(Cells(1, 8), Cells(lastrow, 27)).Value2
bUnion = False

For i = 2 To lastrow

If v1(i, 1) <> "RVWD" Then

If bUnion Then
Set r1 = Union(r1, Cells(i, 1))
Else
Set r1 = Cells(i, 1)
bUnion = True
End If

End If

Next i

r1.EntireRow.Delete


Thank you. sorry if my english is not so good.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Maybe using
Rich (BB code):
If v1(i, 1) <> "RVWD" Or v1(i, 1) <> "RVWDNEW" Or v1(i, 1) <> "APRV" Then
in place of
Rich (BB code):
If v1(i, 1) <> "RVWD" Then
 
Upvote 0
Thanks Momentman,
with your help, I have modified the text as follow and it works.

If v1(i, 1) <> "RVWD" And v1(i, 1) <> "NEW" then

I am first time user of any kind of blog and wow the experience. I love it.
Thanks
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top