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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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