I have a workbook and the macro doesn't work, basically just copying from cell A3 and down with values in each worksheet, then pasting each of that into a new summary worksheet in succession.
When I literally create a new workbook and copy and paste all my sheets into the new workbook everything works fine. But If I stay in the old work book it gives the error
Select Method of Worksheet class failed
It didn't fail in the other 2 workbooks I created with the exact same sheets that I copied over...why this one particular workbook?
I close all other workbooks to avoid error with ActiveWorkBook - perhaps not the best way of doing things, but it shouldn't be affecting this.
Option Explicit
Public Sub SelectItemsEstimate()
Dim ws As Worksheet
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Business Unit Key" _
And ws.Name <> "dv" And ws.Name <> "cc" And ws.Name <> "wer" And ws.Name <> "dafd" _
And ws.Name <> "Master Sheet Summary Data" _
And ws.Name <> "Query for Macro" _
And ws.Name <> "Query for Macro 2 with Format" _
And ws.Name <> "Paste all values" _
And ws.Name <> "Summary" Then
Worksheets(ws.Name).Select
Range("A3", Range("A3").SpecialCells(xlCellTypeLastCell)).Select
Selection.Copy
With ActiveWorkbook.Worksheets("Summary")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row ' get last row with data in column "A"
' paste
.Range("A" & LastRow + 1).PasteSpecial Paste:=xlPasteValues
End With
End If
Next
End Sub
Range("A3", Range("A3").SpecialCells(xlCellTypeLastCell)).Select
is problematic. – BigBen