I have my macro, already created
Sub ConsolidateDestroyData()
Dim ws As Worksheet, wsMaster As Worksheet, LR As Long
Application.ScreenUpdating = 0
Set wsMaster = Sheets("Destroy")
wsMaster.UsedRange.Offset.Clear
For Each ws In ThisWorkbook.Worksheets
With ws
If .Name <> wsMaster.Name And .Name <> "Live" And .Name <> "Data" And .Name <> "Totals" Then
.AutoFilterMode = False
If .Range("H2") <> vbNullString Then
.Rows(1).AutoFilter 8, "1"
LR = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
If LR > 1 Then
.Range("A2:G" & LR).Copy
wsMaster.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlValues
End If
.Rows(1).AutoFilter
End If
End If
End With
Next ws
Application.ScreenUpdating = True
End Sub
I've now decided I want to autorun this macro on opening the workbook. When I add
Private Sub Workbook_Open()
at the beginning it returns an error.
How and where do I add this command?
Bookmarks