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.
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
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
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,553
Messages
5,596,807
Members
414,104
Latest member
imamalidadashzada

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
Top