
Sub Summary_All2()
Dim Sh As Worksheet
Dim Newsh As Worksheet
Dim myCell As Range
Dim ColNum As Long
Dim RwNum As Integer
Dim iSup As Integer
Dim Basebook As Workbook
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Application.DisplayAlerts = False
On Error Resume Next
ThisWorkbook.Worksheets("Summary-Sheet2").Delete
On Error GoTo 0
Application.DisplayAlerts = True
Set Basebook = ThisWorkbook
Set Newsh = Basebook.Worksheets.Add
Newsh.Name = "Summary-Sheet2"
iSup = 1
RwNum = 1
For Each Sh In Basebook.Worksheets
If Sh.Name <> Newsh.Name And Sh.Visible Then
ColNum = 2
iSup = RwNum
For Each myCell In Sh.Range("c3:c1000")
If (myCell <> "") Then
iSup = iSup + 1
Newsh.Cells(iSup, ColNum).Formula = "='" & Sh.Name & "'!" & myCell.Address(False, False)
End If
Next myCell
iSup = RwNum
ColNum = ColNum + 1
For Each myCell In Sh.Range("E3:E1000")
If (myCell <> "") Then
iSup = iSup + 1
Newsh.Cells(iSup, ColNum).Formula = "='" & Sh.Name & "'!" & myCell.Address(False, False)
End If
Next myCell
iSup = RwNum
ColNum = ColNum + 1
For Each myCell In Sh.Range("Bs3:Bs1000") 'PROBLEMATICA
iSup = iSup + 1
If (myCell <> "") Then
Newsh.Cells(iSup, ColNum).Formula = "='" & Sh.Name & "'!" & myCell.Address(False, False)
End If
Next myCell
iSup = RwNum
ColNum = ColNum + 1
For Each myCell In Sh.Range("BT3:BT1000") 'PROBLEMATICA
iSup = iSup + 1
If (myCell <> "") Then
Newsh.Cells(iSup, ColNum).Formula = "='" & Sh.Name & "'!" & myCell.Address(False, False)
End If
Next myCell
RwNum = iSup
End If
Next Sh
Newsh.UsedRange.Columns.AutoFit
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub |
Option Explicit
Sub Summary_All2()
Dim wb As Workbook
Dim ws As Worksheet, wsNew As Worksheet
Dim myCell As Range
Dim ColNum As Long
Dim RwNum As Long, iSup As Long, x As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Application.DisplayAlerts = 0
Set wb = ThisWorkbook
For Each ws In wb.Worksheets
If ws.Name = "Summary-Sheet2" Then
ws.Delete
Exit For
End If
Next ws
Application.DisplayAlerts = 1
Set wsNew = wb.Worksheets.Add
wsNew.Name = "Summary-Sheet2"
iSup = 1
RwNum = 1
For Each ws In wb.Worksheets
If ws.Name <> wsNew.Name And ws.Visible Then
With ws
x = .Range("C" & .Rows.Count).End(xlUp).Row
iSup = wsNew.Range("C" & wsNew.Rows.Count).End(xlUp).Row + 1
wsNew.Range("B2:B" & iSup + x).FormulaR1C1 = "='" & .Name & "'!" & "R[1]C[1]"
x = .Range("E" & .Rows.Count).End(xlUp).Row
iSup = wsNew.Range("C" & wsNew.Rows.Count).End(xlUp).Row + 1
wsNew.Range("C2:C" & iSup + x).FormulaR1C1 = "='" & .Name & "'!" & "R[1]C[1]"
x = .Range("BS" & .Rows.Count).End(xlUp).Row
iSup = wsNew.Range("C" & wsNew.Rows.Count).End(xlUp).Row + 1
wsNew.Range("D2:E" & iSup + x).FormulaR1C1 = "='" & .Name & "'!" & "R[1]C[67]"
End With
End If
Next ws
wsNew.Columns.AutoFit
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub |
