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

  • Thread starter Thread starter Beancounter
  • Start date Start date
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.
 
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.
 
Back
Top