Sorry for what is possibly a very elementary question, but I'm a self-taught beginner!
I'm trying to loop through my workbook and copy a range from each sheet into a new workbook with the name of the tab appended.
The issue is that the range varies from worksheet to worksheet. It always begins at A14 but can have any number of rows, so I tried to set my range to Column I and the Row to the Match position of "Total", less 1.
Logically, I felt pretty good, but every time I put "ws." in front of my initial Range query I get "Method 'Range of object ' _Worksheet' failed". And if I take "ws." away, then my range that copies over stays at the Active workbook.
Any help here would be tremendously appreciated!
Sub forEachECWS()
Dim ws As Worksheet
Dim myRangeL1 As Range
Dim PasteRange As Range
For Each ws In ActiveWorkbook.Worksheets
'Unmerge All Cells
Cells.UnMerge
'Select Loader 1 Range
Set myRangeL1 = ws.Range(Cells(14, "A"), Cells(Application.Match("Total", ws.Range("A:A"), 0) - 1, "I"))
'Copy Loader 1 and paste into Output Workbook, Loader 1 Tab
myRangeL1.Copy
Workbooks("Output Workbook.xlsx").Worksheets("Loader 1").Range("A" & Rows.Count).End(xlUp).Offset(2, 1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Workbooks("Output Workbook.xlsx").Worksheets("Loader 1").Activate
Set PasteRange = Range(Range("A" & Rows.Count).End(xlUp).Offset(2, 0), Cells(Range("F" & Rows.Count).End(xlUp).Row, "A"))
Workbooks("Origin Workbook").Activate
PasteRange = ws.Name
Next
End Sub