Results 1 to 7 of 7

vertical transposition macro

Threaded View

  1. #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: vertical transposition macro

    Try this:
    Option Explicit
    
    Sub TransposeWIP()
    Dim Sizes As Range, Itms As Range
    Dim SzRws As Long, Rw As Long
    
    'Setup
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    'clear output sheet if it exists
    If Evaluate("ISREF(Results!A1)") Then Sheets("Results").Delete
    
    'duplicate activesheet to create new output sheet
    ActiveSheet.Copy After:=Sheets(Sheets.Count)
    ActiveSheet.Name = "Results"
    
    'insert new columns and clear WIP totals
    Range("AM:AN").Insert xlShiftToRight
    On Error Resume Next
    Range("AL:AL").SpecialCells(xlConstants, xlNumbers).ClearContents
    On Error GoTo 0
    
    'Sizes to copy/transpose
    Set Sizes = Range("AP2:AY2")
    SzRws = 10
    
    'Rows to process
    Set Itms = Range("F:F").SpecialCells(xlConstants, xlNumbers)
    
    'Loop each row from the bottom up inserting values needed
    For Rw = Itms.Rows.Count + 2 To 3 Step -1
        Range("A" & Rw).Offset(1).Resize(SzRws - 1).EntireRow.Insert xlShiftDown
        Range("AM" & Rw).Resize(SzRws).Value = _
            Application.WorksheetFunction.Transpose(Sizes)
        Range("AN" & Rw).Resize(SzRws).Value = _
            Application.WorksheetFunction.Transpose(Range("AP" & Rw, "AY" & Rw))
        Range("E" & Rw, "G" & Rw).Resize(SzRws).Value = _
            Range("E" & Rw, "G" & Rw).Value
        Range("AG" & Rw, "AK" & Rw).Resize(SzRws).Value = _
            Range("AG" & Rw, "AK" & Rw).Value
    Next Rw
    
    'Cleanup
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    _________________
    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!)

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