cutting and pasting data within a worksheet, from one sheet toanother, using selection criteria

B

Beancounter

I want to cut and paste a line of date (a whole row) from one
worksheet to another based upon a certain criteria.

For example, I have Sheet-A containing 5 columns, the first (a)
contains a part number that is repeated, I want to pull any line that
contains a certain part number over to a new Sheet – B. Last but not
least, delete the rows in the original file containing the part
number.

Thanks in advance.
 
J

JLGWhiz

Give this a try:


Sub moveStuff()
Dim lr As Long, sh As Worksheet, myPN As String
Set sh = ActiveSheet 'Change to actual Sheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
myPN = InputBox("Enter Part Number to Search")
For i = lr To 2 Step -1
If Range("A" & i).Value = myPN Then
Range("A" & i).EntireRow.Copy
Sheets(2).Range("A2").Insert
End If
Next
End Sub




I want to cut and paste a line of date (a whole row) from one
worksheet to another based upon a certain criteria.

For example, I have Sheet-A containing 5 columns, the first (a)
contains a part number that is repeated, I want to pull any line that
contains a certain part number over to a new Sheet – B. Last but not
least, delete the rows in the original file containing the part
number.

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top