I have an excel spreadsheet with 102 tabs-- each tab is formatted in the same way with several columns of operations. I want to copy the same column of data from each tab and put it on a single tab within the same worksheet, but I don't know how to paste each copy into a different column.
This question is very similar to the one asked here: Extract tabular data from every Excel tab, and paste data on a single sheet
I have tried many variations on the following code, but cannot figure it out. I am getting the following error:
Method 'Range' of object '_Worksheet' failed
I have pasted the code below. Thanks in advance for any and all help!
Option Explicit
Sub CopyPasteCombineSI()
Dim wsInput As Worksheet, wsOutput As Worksheet
Dim rngSI As Range, rngHeading As Range
Dim LColO As Long, LRowI As Long, LastColumn As Long
'~~> Set your Output Sheet
Set wsOutput = ThisWorkbook.Sheets("Dual Flow")
'~~> Loop through all sheets to copy and paste combined SI data
For Each wsInput In ThisWorkbook.Worksheets
    '~~> Ensure that we ignore the output sheet
    If wsInput.Name <> wsOutput.Name Then
        '~~> Working with the input sheet
        With wsInput
            '~~> Set your range for copying
            Set rngHeading = .Range("E1")
            '~~> Copy your range
            rngHeading.Copy
            '~~> Paste
            .Range("F1").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
            '~~> Get the last row of input sheet
            LRowI = .Range("A" & .Rows.Count).End(xlUp).Row
            '~~> Set your range for copying
            Set rngSI = .Range("F1:F" & LRowI)
            '~~> Copy your range
            rngSI.Copy
            '~~> Pasting data in the output sheet
            With wsOutput
                If WorksheetFunction.CountA(Cells) > 0 Then
                    'Search for any entry, by searching backwards by Columns.
                    LastColumn = Cells.Find(What:="*", After:=[A1], _
                    SearchOrder:=xlByColumns, _
                    SearchDirection:=xlPrevious).Column
                Else
                    LastColumn = 0
                End If
                '~~> Get the next available column in output sheet for pasting
                LColO = LastColumn + 1
                '~~> Finally paste
                .Range(LColO & "1").PasteSpecial Paste:=xlPasteValues, _
                Operation:=xlNone, SkipBlanks:=False, Transpose:=False
            End With
        End With
    End If
Next wsInput
Exit Sub
End Sub
 
     
    