ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cutting and pasting data within a worksheet, from one sheet toanother, using selection criteria (https://www.excelbanter.com/excel-programming/439836-cutting-pasting-data-within-worksheet-one-sheet-toanother-using-selection-criteria.html)

Beancounter

cutting and pasting data within a worksheet, from one sheet toanother, using selection criteria
 
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.

JLGWhiz[_2_]

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.




All times are GMT +1. The time now is 06:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com