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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,213,520
Messages
6,114,099
Members
448,548
Latest member
harryls

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