Delete rows based on a criteria in a range

coetzej9

New Member
Joined
Mar 4, 2016
Messages
5
Yes, if you dont want to delete the first row at all, where I have defined the value of c = 1 change to c=2 everywhere. That way it will start on the second row instead of the first. Let me know if this is what you are lookign for. Thanks

Hi,

I would like to delete rows only in "RawData1" using criteria for a RANGE of values, let's say in "MENU" A2:A5. So far I used the following code:

PHP:
Sub Remove()
Set a = Sheets("Menu")
Set b = Sheets("Raw Data1")
Dim c As Integer
c = 2

Do Until IsEmpty(b.Range("A" & c))

If a.Range("A" & 2) <> b.Range("A" & c) Then
b.Range("A" & c).EntireRow.Delete
c = c - 1
End If

c = c + 1
Loop

End Sub

But with my somewhat limited coding knowledge I do not know how to specify the range for "MENU" A2:A5 so that VBA looks not for a range "set" as opposed to the individual values in the range.

Thanks,
coetzej9
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi Coet!

It almost sounds like a named range would solve the problem for you if you weren't deleting that named range. Are you going to keep the headers and just clear the contents of the cell?
 
Upvote 0
Hi Coet!

It almost sounds like a named range would solve the problem for you if you weren't deleting that named range. Are you going to keep the headers and just clear the contents of the cell?

Hi,

Thank you for the reply. I have a macro auto sizing the range with the source info. Yes, I would like to keep the headers and clear the cell contents.

Regards,
C
 
Upvote 0

Forum statistics

Threads
1,203,119
Messages
6,053,622
Members
444,674
Latest member
Fieldy1999

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