Move every 2nd row to the end of previous row

clauspeter

New Member
Joined
Aug 14, 2023
Messages
2
Office Version
  1. 2010
Platform
  1. Windows
App 2500 rows of data. Yellow A2,B2,C2,D2 must be moved to grey E1,F1,G1,H1. Do I type the instructution/formula behind fx
Thank you very much and regards ...peter

1692000589813.png
1692000395105.png
 

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.
Welcome to the MrExcel Message Board!

I assumed the empty rows will be deleted. In that case, please try the following VBA code as it is.
Otherwise, if you'd like to keep the empty rows instead, disable the rw.Delete xlShiftUp line, and enable the next line, rw.ClearContents in the code.
VBA Code:
Sub doCleanUp()
Dim rng As Range
Dim rw As Range
    Set rng = ActiveSheet.Cells(1, 1).CurrentRegion
    For Each rw In rng.Rows
        If rw.Cells(1, 1).Value = "" Then
            rw.Offset(-1).Offset(, rng.Columns.Count).Resize(, rng.Columns.Count).Cells.Formula = rw.Cells.Formula
            rw.Delete xlShiftUp
            'rw.ClearContents
        End If
    Next rw
End Sub
 
Upvote 0
Thanks you sir
You're welcome.

If the provided code/method helped you, please mark the post that answered your question as the solution by using the little circled checkmark right next to that post. This way, it will help future readers.

Otherwise, if the provided solution didn't help, then please let us know by explaining how the provided solution didn't work for you.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
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