Excel Question

Hello

Have one Excel Sheet,  how can I change structure from one row to multiple rows as shown below :

Current :
1      A      B      C      D
2      A      R      X      
3      Z      F            
4      C

Required :
1 A
1 B
1 C
1 D
2 A
2 R
2 X
3 Z
3 F
4 C
m_jundiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ProfessorJimJamCommented:
please see my answer to the exact question previously answered in another thread

http://www.experts-exchange.com/questions/28702712/transpose-columns-to-rows.html
0
m_jundiAuthor Commented:
How to Use it ?
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You can try the below code to achieve the desired output.
Please find the attached workbook and click on the button on Sheet1 to get the desired output on the newly created Data Sheet.
Sub RearrangData()
Dim sws As Worksheet, ws As Worksheet
Dim LastRow As Long, LastCol As Long, r As Long, c As Long

Application.ScreenUpdating = False
Set sws = Sheets("Sheet1")
LastRow = sws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
On Error Resume Next
Set ws = Sheets("Data")
ws.Cells.Clear
If Err <> 0 Then
    Worksheets.Add(after:=Sheets(Sheets.Count)).Name = "Data"
    Set ws = ActiveSheet
End If

For r = 1 To LastRow
    LastCol = sws.Cells(r, Columns.Count).End(xlToLeft).Column
    If ws.Range("A1").Value = "" Then
        sws.Cells(r, 1).Copy ws.Range("A1").Resize(LastCol - 1, 1)
        sws.Range(sws.Cells(r, 2), sws.Cells(r, LastCol)).Copy
        ws.Range("B1").PasteSpecial xlPasteValues, Transpose:=True
    Else
        sws.Cells(r, 1).Copy ws.Range("A" & Rows.Count).End(3)(2).Resize(LastCol - 1, 1)
        sws.Range(sws.Cells(r, 2), sws.Cells(r, LastCol)).Copy
        ws.Range("B" & Rows.Count).End(3)(2).PasteSpecial xlPasteValues, Transpose:=True
    End If
Next r
ws.Activate
ws.Range("A1").Select
Application.CutCopyMode = 0
Application.ScreenUpdating = True
MsgBox "Data has been rearranged successfully.", vbInformation, "Done!"
End Sub

Open in new window

ReArrangeData.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
m_jundiAuthor Commented:
Worked Perfect
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Glad to know that. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.