+ Reply to Thread
Results 1 to 3 of 3

vba code to transpose vertically

Hybrid View

  1. #1
    Registered User
    Join Date
    10-16-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    20

    vba code to transpose vertically

    Hi! I don't have much time to browse through the posts that might be able to help me, so I'm posting a file similar to the one I'm working with.

    I'd like to get help with working out with a vba code that'll be able to transpose data vertically.
    Attached Files Attached Files

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: vba code to transpose vertically

    Hi, try it
    Sub ertert()
    Dim x, y(), i&, j&, k&
    x = Sheets("Sheet1").Range("A1").CurrentRegion.Value
    ReDim y(1 To UBound(x) * UBound(x, 2), 1 To 3)
    For i = 2 To UBound(x)
        For j = 2 To UBound(x, 2) Step 2
            If Len(x(i, j)) Then
                k = k + 1
                y(k, 1) = x(i, 1): y(k, 2) = x(i, j): y(k, 3) = x(i, j + 1)
            End If
        Next j
    Next i
    With Sheets("Sheet2")
        .UsedRange.ClearContents
        .Range("A1:C1").Value = Array("Company", "b", "c")
        .Range("A2:C2").Resize(k).Value = y: .Activate
    End With
    End Sub
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    10-16-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: vba code to transpose vertically

    works magic! thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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