View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default cutting and pasting data within a worksheet, from one sheet to another, using selection criteria

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




"Beancounter" wrote in message
...
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.