Remove rows and move data

dknowles2004

Board Regular
Joined
Nov 15, 2004
Messages
79
Please help!! I have a spreadsheet with two rows per product (hundreds of rows). I'm trying to move the values in the second row to Columns D and E of the preceding row. For example,

Rows 3 and 4. Move values in Row 4 to Row 3, Column D and E then delete Row 4. Obviously, each time the row is deleted, the references of the remaining rows will change!!

Then I need to repeat this for all the remaining rows.

Any ideas? I'm desperate.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi

the code moves data in even row to one above
Code:
Sub moveEvenData()
Dim r As Range
Application.ScreenUpdating = False
With ActiveSheet
    For Each r In .Range("a1", .Range("a65536").End(xlUp))
        If r.Row Mod 2 = 0 Then
            r.Resize(1, 2).Cut Destination:=r.Offset(-1, 2)
        End If
    Next
    .Range("a1", "d" & .Range("a65536").End(xlUp).Row).Sort key1:=.Range("a1")
End With
Application.ScreenUpdating = True
End Sub
you don't need to delete the remaining blank rows, just sort then.

rgds,

jindon
 
Upvote 0
Hi

Refer to your PM to me
change
Code:
    For Each r In .Range("a1", .Range("a65536").End(xlUp)) 
        If r.Row Mod 2 = 0 Then 
            r.Resize(1, 2).Cut Destination:=r.Offset(-1, 2) 
        End If 
    Next

to:
Code:
    For Each r In .Range("a1", .Range("a65536").End(xlUp))
        If r.Row Mod 2 = 0 Then
            r.Offset(, 1).Resize(1, 2).Cut Destination:=r.Offset(-1, 2)
        End If
    Next

rgds,
jindon
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,575
Members
449,039
Latest member
Arbind kumar

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