Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This code copies the last column from every sheet and pastes them as rows in the <code>MainSheet</code> keeping the merged cells intact.</p> <pre><code>Option Explicit Sub Sample() Dim wsI As Worksheet, wsO As Worksheet Dim wsOLrow As Long, wsILrow As Long, wsILcol As Long On Error GoTo Whoa Application.ScreenUpdating = False Set wsO = Sheets("MainSheet") wsOLrow = wsO.Cells.Find(What:="*", _ After:=wsO.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row + 1 For Each wsI In ThisWorkbook.Sheets If wsI.Name &lt;&gt; wsO.Name Then With wsI wsILrow = .Cells.Find(What:="*", _ After:=.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row wsILcol = .Cells.Find(What:="*", _ After:=.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Column .Range(Split(Cells(, wsILcol).Address, "$")(1) &amp; "1:" &amp; _ Split(Cells(, wsILcol).Address, "$")(1) &amp; _ wsILrow).Copy .Range(Split(Cells(, wsILcol + 1).Address, "$")(1) &amp; "1:" &amp; _ Split(Cells(, wsILcol + 1).Address, "$")(1) &amp; wsILrow) .Activate With .Range(Split(Cells(, wsILcol + 1).Address, "$")(1) &amp; "1:" &amp; _ Split(Cells(, wsILcol + 1).Address, "$")(1) &amp; wsILrow) .UnMerge .Cells.SpecialCells(xlCellTypeBlanks).Delete shift:=xlUp End With wsILrow = .Range(Split(Cells(, wsILcol).Address, "$")(1) &amp; Rows.Count).End(xlUp).Row With .Range(Split(Cells(, wsILcol + 1).Address, "$")(1) &amp; "1:" &amp; _ Split(Cells(, wsILcol + 1).Address, "$")(1) &amp; wsILrow) .Copy wsO.Cells(wsOLrow, 1).PasteSpecial Paste:=xlPasteAll, _ Operation:=xlNone, SkipBlanks:=False, Transpose:=True .Delete End With wsOLrow = wsOLrow + 1 End With End If Next LetsContinue: Application.ScreenUpdating = True MsgBox "Done" Exit Sub Whoa: MsgBox Err.Description Resume LetsContinue End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload