Move values from columns to new rows

BioPA

New Member
Joined
Oct 26, 2013
Messages
30
Hello everybody!

I 'd appreciate if somebody helped me on this:

I have N rows of data separated into 4 columns

ABCD
1VALUE1iVALUE1iiVALUE1iiiVALUE1iv
2VALUE2iVALUE2iiVALUE2iiiVALUE2iv
3VALUE3iVALUE3iiVALUE3iiiVALUE3iv
NVALUENiVALUENiiVALUENiiiVALUENiv

<tbody>
</tbody>


I would like to take the values from C and D columns and move them behind
the first 2, so that

AB
1VALUE1iVALUE1ii
2VALUE1iiiVALUE1iv
3VALUE2iVALUE2ii
4VALUE2iiiVALUE2iv
5VALUE3iVALUE3ii
6VALUE3iiiVALUE3iv
7VALUENiVALUENii
8VALUENiiiVALUENiv

<tbody>
</tbody>

So, now we have 2 columns, 2 new inserted rows with the cell values from column C & D.

Is it possible to have a macro for that?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Maybe this:
Code:
Sub a939920()
Dim va, vc, i As Long, j As Long

va = Range("A1", Cells(Rows.count, "D").End(xlUp)).Value
ReDim vc(1 To UBound(va, 1) * 2, 1 To 2)
j = 1
For i = 1 To UBound(va, 1)
    vc(j, 1) = va(i, 1)
    vc(j, 2) = va(i, 2)
    vc(j + 1, 1) = va(i, 3)
    vc(j + 1, 2) = va(i, 4)
    j = j + 2
Next
Range("A1", Cells(Rows.count, "D").End(xlUp)).ClearContents
Range("A1").Resize(UBound(va, 1) * 2, 2) = vc

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,367
Members
449,080
Latest member
Armadillos

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