Private Sub UserForm_Terminate()
'------------------------------------------------------
Dim iLoop As Long, bScratch As Boolean, bTemp As Boolean, bSummary As Boolean, bMatched As Boolean
bScratch = False: bTemp = False: bSummary = False: bMatched = False
'------------------------------------------------------
'------------------------------------------------------
'Loop through ALL the tabs in the book - check for the sheets that were temporary - set Boolean Flag for deletion if found
For iLoop = 1 To Sheets.Count
If Worksheets(iLoop).Name = "Scratch" Then bScratch = True
If Worksheets(iLoop).Name = "Temp" Then bTemp = True
If Worksheets(iLoop).Name = "Summary" Then bSummary = True
If Worksheets(iLoop).Name = "Matched" Then bMatched = True
Next iLoop
'------------------------------------------------------
'------------------------------------------------------
'If Boolean Flag was set (Sheet found) - delete tab
Application.DisplayAlerts = False
If bScratch = True Then Worksheets("Scratch").Delete
If bTemp = True Then Worksheets("Temp").Delete
If bSummary = True Then Worksheets("Summary").Delete
If bMatched = True Then Worksheets("Matched").Delete
Application.DisplayAlerts = True
'------------------------------------------------------
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
'Release memory - Public Arrays:
Erase aHeaderH:
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Worksheets(1).Select
End Sub
'------------------------------------------------------
Dim iLoop As Long, bScratch As Boolean, bTemp As Boolean, bSummary As Boolean, bMatched As Boolean
bScratch = False: bTemp = False: bSummary = False: bMatched = False
'------------------------------------------------------
'------------------------------------------------------
'Loop through ALL the tabs in the book - check for the sheets that were temporary - set Boolean Flag for deletion if found
For iLoop = 1 To Sheets.Count
If Worksheets(iLoop).Name = "Scratch" Then bScratch = True
If Worksheets(iLoop).Name = "Temp" Then bTemp = True
If Worksheets(iLoop).Name = "Summary" Then bSummary = True
If Worksheets(iLoop).Name = "Matched" Then bMatched = True
Next iLoop
'------------------------------------------------------
'------------------------------------------------------
'If Boolean Flag was set (Sheet found) - delete tab
Application.DisplayAlerts = False
If bScratch = True Then Worksheets("Scratch").Delete
If bTemp = True Then Worksheets("Temp").Delete
If bSummary = True Then Worksheets("Summary").Delete
If bMatched = True Then Worksheets("Matched").Delete
Application.DisplayAlerts = True
'------------------------------------------------------
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
'Release memory - Public Arrays:
Erase aHeaderH:
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Worksheets(1).Select
End Sub