Create a macro to find a value in a table, copy the entire row and insert it to a new sheet?

Status
Not open for further replies.

Garrek

Board Regular
Joined
Aug 22, 2019
Messages
53
I'm looking to create a macro to look up a given value in a table, cut the entire row that the value is in, and paste it at the bottom of a different sheet.

The lookup value is located at cell B14 of Sheet1, it will later be tied to a userform. The table with the list of values in on Sheet2, and the lookup value will always be found in column A of the table. The row lengths vary from 4 cells up to 11. It will be replacing the row onto a table on sheet 3, where I will alphabetize it by column A.

Essentially, Sheet2 contains active items and sheet 3 contains retired items, but it is useful to still have them for reference. Could anyone help with this?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hello,

Does this code work as expected?

Code:
Sub MOVE_TO_SHEET_3()
    Application.ScreenUpdating = False
    With Sheets("Sheet2")
        For MY_ROWS = .Range("A" & .Rows.Count).End(xlUp).Row To 1 Step -1
            If .Range("A" & MY_ROWS).Value = Sheets("Sheet1").Range("B14").Value Then
                .Rows(MY_ROWS).Copy
                Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
                .Rows(MY_ROWS).Delete
            End If
        Next MY_ROWS
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,748
Messages
6,180,721
Members
452,995
Latest member
isldboy

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