• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need code to copy paste the each column data under one column

vinu

Member
Hello team,


Could you please help me for the below scenario:


Need a code to copy paste column data under one column and keep the same description.


A B C


bang mys


jan 645 978

feb 645

mar 978


it should be realigned like below: no of rows and column keep adding need to looping.


A B C


bang jan 645

bang feb

bag mar 978

mys jan 978

mys feb 645

mys mar


thanks.
 
This code should work. Note that you need to define what range to use and what row you want to start the new table on.


Code:
Sub Reorder()

Dim MyRange As Range

Dim NewRow As Integer

Dim xWide As Integer

Dim xTall As Integer

Dim StartRow As Integer


Application.ScreenUpdating = False

'Define this range as appropriate

Set MyRange = Range("A1:C4")


xWide = MyRange.Columns.Count

xTall = MyRange.Rows.Count


'Which row do you want the new table to start

StartRow = 10


For i = 2 To xWide

For j = 2 To xTall

Cells(StartRow, 1) = MyRange.Cells(1, i)

Cells(StartRow, 2) = MyRange.Cells(j, 1)

Cells(StartRow, 3) = MyRange.Cells(j, i)

StartRow = StartRow + 1

Next j

Next i


End Sub
 
Back
Top