Sort and delete data

hobo

New Member
Joined
Nov 2, 2005
Messages
4
Hi Guys,

I'v ebeen a long time reader but never needed to ask a question before... but i am just haveing to much trouble trying to sort this issue out.

In Sheet1 i have this data:

Mark, Quantity, etc..
123-m-1 1
124-m-1 2
125-m-1 3
126-m-1 1
127-m-1 1
128-m-1 2
129-m-1 1
130-m-1 1
131-m-1 1
etc

In Sheet2 i have
Mark,
124-m-1
128-m-1
131-m-1

I want to delete rows in Sheet1 that do not match the Mark number that i have in Sheet2 so that i am left with only the relevant fields to update and upload into my database.

Cheers,
Ant
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Ant

How about
Code:
Sub aaa()
 Sheets("sheet1").Select
 For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
  If WorksheetFunction.CountIf(Sheets("sheet2").Range("A:A"), Cells(i, "A")) = 0 Then
   Cells(i, "A").EntireRow.Delete
  End If
 Next i
End Sub


Tony
 
Upvote 0

Forum statistics

Threads
1,224,427
Messages
6,178,587
Members
452,860
Latest member
jroberts02

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