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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,079
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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
 

csl6989

New Member
Joined
Jan 2, 2014
Messages
3
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
 

Watch MrExcel Video

Forum statistics

Threads
1,129,577
Messages
5,637,201
Members
416,960
Latest member
Carbon1198

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
Top