Private Sub Worksheet_Activate()
Dim lo As ListObject
Dim lr As ListRow
Dim rngSource As Range
Dim rngDest As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Set lo = [Summary].ListObject
With lo
On Error Resume Next
.DataBodyRange.Rows.Delete
On Error GoTo 0
Set rngSource = [1].ListObject.DataBodyRange
Set rngDest = .HeaderRowRange.Offset(1)
rngSource.Copy rngDest.Resize(rngSource.Rows.Count)
Set rngSource = [2].ListObject.DataBodyRange
Set rngDest = .HeaderRowRange.Offset(1)
rngSource.Copy rngDest.Resize(rngSource.Rows.Count)
Set rngSource = [3].ListObject.DataBodyRange
Set rngDest = .HeaderRowRange.Offset(1)
rngSource.Copy rngDest.Resize(rngSource.Rows.Count)
Set rngSource = [4].ListObject.DataBodyRange
Set rngDest = .HeaderRowRange.Offset(1)
rngSource.Copy rngDest.Resize(rngSource.Rows.Count)
With .Sort
.SortFields.Clear
.SortFields. _
Add Key:=Range("Summary[[#All],[Days In Queue]]"), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Option Explicit
Private Sub Worksheet_Activate()
Dim lo As ListObject
Dim lr As ListRow
Dim rngSource As Range
Dim rngDest As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Set lo = [Summary].ListObject
With lo
On Error Resume Next
.DataBodyRange.Rows.Delete
On Error GoTo 0
'Copy the first source table into the Summary table.
Set rngSource = [ReferenceA].ListObject.DataBodyRange
Set rngDest = .HeaderRowRange.Offset(1)
rngSource.Copy rngDest.Resize(rngSource.Rows.Count)
Set rngSource = [ReferenceB].ListObject.DataBodyRange
Set rngDest = .ListRows.Add.Range
rngDest.Resize(rngSource.Rows.Count).Value = rngSource.Value
Set rngSource = [ReferenceC].ListObject.DataBodyRange
Set rngDest = .ListRows.Add.Range
rngSource.Copy rngDest.Resize(rngSource.Rows.Count)
Set rngSource = [REferenceD].ListObject.DataBodyRange
Set rngDest = .ListRows.Add.Range
rngDest.Resize(rngSource.Rows.Count).Value = rngSource.Value
With .Sort
.SortFields.Clear
.SortFields. _
Add Key:=Range("Summary[[#All],[Days In Queue]]"), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub