+ Reply to Thread
Results 1 to 4 of 4

Transpose column sections into sequential rows of new sheet, Macro help

Hybrid View

  1. #1
    Registered User
    Join Date
    05-10-2012
    Location
    Twin Cities, MN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Transpose column sections into sequential rows of new sheet, Macro help

    Hey guys,

    I would appreciate some help so I can import data into a statistics program.

    I need to transpose every three cells of a column into sequential rows of a new sheet.

    Specifically, for columns 3-49 I need to create a new sheet named after the text of row 1 of each column. Then, for each new sheet, I need to transpose every three cells from the column it was named after into sequential rows. In other words, I need to tranpose the cells in rows 2-4 of that col, into a row in the new sheet, then cells 5-7 all the way to row 283.

    Thank you for any hope in advance.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Transpose column sections into sequential rows of new sheet, Macro help

    This should do it:

    Option Explicit
    
    Sub ColumnsToSheets()
    Dim ws As Worksheet, MyRNG As Range
    Dim Rw As Long, NR As Long, Col As Long
    
    With ActiveSheet
        Application.ScreenUpdating = False
        For Col = 3 To 49
            If Len(.Cells(1, Col)) > 0 Then                                 'cell isn't blank in row1
                If Not Evaluate("ISREF('" & .Cells(1, Col) & "'!A1)") Then  'sheet doesn't already exist
                    Sheets.Add(after:=Sheets(Sheets.Count)).Name = .Cells(1, Col)   'create sheet
                    NR = 1                                                  'set first row to add into
                    For Rw = 2 To .Cells(.Rows.Count, Col).End(xlUp).Row Step 3   'copy data, set next row
                        Range("A" & NR).Resize(, 3).Value = WorksheetFunction.Transpose(.Cells(Rw, Col).Resize(3))
                        NR = NR + 1
                    Next Rw
                    Columns.AutoFit
                End If
            End If
        Next Col
        .Activate
        Application.ScreenUpdating = True
    End With
    
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-10-2012
    Location
    Twin Cities, MN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Transpose column sections into sequential rows of new sheet, Macro help

    Thank you so much for your help.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Transpose column sections into sequential rows of new sheet, Macro help

    If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

+ 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