+ Reply to Thread
Results 1 to 10 of 10

Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

Hybrid View

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Question Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    Hello Friends,

    I am in trouble of converting Vertical Columns to Horizontal Rows. I used Transpose function but I have too many data to perform the Transpose function.

    Is there any other formula to do it in simple manner, which can work on large data smoothly??

    My data file is attached here with for your reference.

    Thanks in Advance.
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    This can be easily done with a small macro. Would you be interested?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-07-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    Yes, I am interested. Please help me.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    Try this code
    Option Explicit
    
    Sub transpose_data()
    Dim i As Long, lrow As Long, lcol As Long, lcol1 As Long
    
    Application.ScreenUpdating = False
    
    With Worksheets("current data")
        lrow = .Range("B" & .Rows.Count).End(xlUp).Row
        For i = lrow To 2 Step -1
            If .Range("A" & i).Value = "" Then
                lcol = .Range("IV" & i - 1).End(xlToLeft).Column
                lcol1 = .Range("IV" & i).End(xlToLeft).Column
                .Range(.Cells(i, 2), .Cells(i, lcol1)).Copy .Cells(i - 1, lcol + 1)
                Application.CutCopyMode = False
                .Rows(i).Delete
            End If
        Next i
    End With
    
    MsgBox "Done"
    Application.ScreenUpdating = True
    
    End Sub
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

  5. #5
    Registered User
    Join Date
    05-07-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    Hello, I think I was not able to communicate my problem properly.

    In my attached file there are two sheets, first is "Current Data" which I downloaded from ERP system in to Excel, I need a formula or Macro so that I get the result as shown in my second sheet "want result by Formula"

    Hope it is clear now.

    Please help.

    Best Regards,

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    Ok, so the output is fine right? It just needs to show up in a different sheet?

  7. #7
    Registered User
    Join Date
    05-07-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    Yes, you are right. I want the result in a different sheet with out disturbing original data.

    I must thank you for your help.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    Try this
    Option Explicit
    
    Sub transpose_data()
    Dim i As Long, lrow As Long, lcol As Long, lcol1 As Long
    Dim ws As Worksheet
    
    Application.ScreenUpdating = False
    
    Set ws = Worksheets("want result by Formula")
    ws.Cells.ClearContents
    
    Worksheets("current data").Cells.Copy ws.Range("A1")
    
    With ws
        lrow = .Range("B" & .Rows.Count).End(xlUp).Row
        For i = lrow To 2 Step -1
            If .Range("A" & i).Value = "" Then
                lcol = .Range("IV" & i - 1).End(xlToLeft).Column
                lcol1 = .Range("IV" & i).End(xlToLeft).Column
                .Range(.Cells(i, 2), .Cells(i, lcol1)).Copy .Cells(i - 1, lcol + 1)
                Application.CutCopyMode = False
                .Rows(i).Delete
            End If
        Next i
    End With
    
    MsgBox "Done"
    Application.ScreenUpdating = True
    
    End Sub

  9. #9
    Registered User
    Join Date
    05-07-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    I am very very thankful to you, I tried to thank you earlier also but having some internet issues. You are truly a genius.

    Many Many thanks again.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)

    Since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1