I'm still pretty new with VBA (learning for work, coming from a JS background) and I need a little help with this. My goal is: loop through each worksheet (except the "Summary" sheet, although I'm not sure how to exclude this from the loop) in the workbook and copy A2 in each sheet, as well as the last cell containing a value in column L of each sheet, and paste those next to each other in columns A and B on the "Summary Sheet", respectively. I'm not an expert with VBA syntax by any means, so if anyone has any way to refactor this (I know I don't need all the .select methods), I would appreciate it. Right now I'm getting an "invalid or unqualified reference" error on line 28. My goal is to learn, so if you have any input I would appreciate a short explanation of the logic. Thanks.
Sub Macro7()
'
' Macro7 Macro
'
' Keyboard Shortcut: Ctrl+c
Dim ws As Worksheet
Dim lastRow As Integer
Dim summaryRow As Integer
summaryRow = 1
For Each ws In ActiveWorkbook.Worksheets
'Copy item number and paste on Summary Page'
Range("A2").Select
Selection.Copy
Sheets("Summary").Select
Range("A" & summaryRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Copy corresponding BOM item # and paste on Summary Page'
ws.Select
lastRow = .Cells(.Rows.Count, "L").End(xlUp).Row
Range("L" & lastRow).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Summary").Select
Range("B" & summaryRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
summaryRow = summaryRow + 1
Next ws
End Sub