Copy entire row into column

justkodian

New Member
Joined
Jun 5, 2019
Messages
2
I have a spreadsheet with items similar to below:[TABLE="width: 500"]
<tbody>[TR]
[TD]#[/TD]
[TD]item code[/TD]
[TD]item description[/TD]
[TD]item size[/TD]
[TD]notes[/TD]
[TD]cost[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]001[/TD]
[TD]Tool Box Prepack[/TD]
[TD]1UN[/TD]
[TD][/TD]
[TD]47.75[/TD]
[/TR]
[TR]
[TD]CONTAINS:[/TD]
[TD]0001[/TD]
[TD]Screwdriver[/TD]
[TD]1UN[/TD]
[TD][/TD]
[TD]2.79[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]002[/TD]
[TD]Ladder[/TD]
[TD]1UN[/TD]
[TD][/TD]
[TD]87.79[/TD]
[/TR]
</tbody>[/TABLE]

I am trying to create a macro that will search for the word "Prepack" in column C and when it finds it to cut the entire row(s) below it that have "CONTAINS:" in column A..the trickier part is they need to be pasted next to end of the row with "Prepack"

so it would look like this after:
[TABLE="width: 500"]
<tbody>[TR]
[TD]#[/TD]
[TD]item code[/TD]
[TD]item description[/TD]
[TD]item size[/TD]
[TD]notes[/TD]
[TD]cost[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]001[/TD]
[TD]Tool Box Prepack[/TD]
[TD]1UN[/TD]
[TD][/TD]
[TD][/TD]
[TD]CONTAINS:[/TD]
[TD]0001[/TD]
[TD]Screwdriver[/TD]
[TD]1UN[/TD]
[TD][/TD]
[TD]2.79[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]002[/TD]
[TD]Ladder[/TD]
[TD]1UN[/TD]
[TD][/TD]
[TD]87.79[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

****** id="cke_pastebin" style="position: absolute; top: 197px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">[TABLE="width: 500"]
<tbody>[TR]
[TD]item code[/TD]
[TD]item description[/TD]
[TD]item size[/TD]
[TD]notes[/TD]
[TD]cost[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]001[/TD]
[TD]Tool Box Prepack[/TD]
[TD]1UN[/TD]
[TD][/TD]
[TD]47.75[/TD]
[/TR]
</tbody>[/TABLE]
</body>And if there are multiple rows below the prepack with CONTAINS: all of the rows get cut and pasted beside

Thanks for the help.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try this

Code:
Sub Copy_entire_row()
    Dim i As Long
    For i = Range("C" & Rows.Count).End(xlUp).Row To 2 Step -1
        If LCase(Cells(i, "C").Value) Like "*" & LCase("Prepack") & "*" Then
            Range(Cells(i + 1, "A"), Cells(i + 1, "F")).Copy Cells(i, "G")
            Rows(i + 1).Delete
        End If
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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