Sub Add_All_Worksheets()
ActiveWorkbook.Sheets.Add after:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count).Name = "Total"
Dim wSheet As Worksheet
Dim rCopy As Range
Dim rPaste As Range
Dim lngLastRow As Long
Dim lngLastRowCons As Long
Dim strConsTab As String
strConsTab = "Total" 'Consolidation sheet tab name
'Clear any existing data from the consolidation tab or else each _
sheet in the work will keep appending to it each time the macro is run.
lngLastRowCons = Sheets(strConsTab).Cells(Rows.Count, "A").End(xlUp).Row
If lngLastRowCons > 1 Then
Sheets(strConsTab).Range("A2:U" & lngLastRowCons).ClearContents
End If
For Each wSheet In Worksheets
If wSheet.Name <> strConsTab Then
With wSheet
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set rCopy = .Range("U7")
End With
lngLastRowCons = Sheets(strConsTab).Cells(Rows.Count, "A").End(xlUp).Row
lngLastRowCons = lngLastRowCons + 1
Set rPaste = Sheets(strConsTab).Range("A" & lngLastRowCons)
rCopy.Copy
rPaste.PasteSpecial xlValues
Application.CutCopyMode = False
End If
Next wSheet
Range("A2").Select
End Sub
Option Explicit
Sub Macro1()
'http://www.mrexcel.com/forum/showthread.php?t=578536
Dim wrkSheet As Worksheet
Dim strConsSheet As String
Dim lngOutputRowNum As Long
Application.ScreenUpdating = False
strConsSheet = ActiveSheet.Name
For Each wrkSheet In ThisWorkbook.Sheets
If wrkSheet.Name <> strConsSheet Then
With Sheets(strConsSheet).Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1)
.Formula = "=" & wrkSheet.Name & "!$U$7"
.Value = .Value 'Convert link to a value. Delete or comment out if not required.
End With
End If
Next wrkSheet
Application.ScreenUpdating = True
End Sub
Yes, I have an arsenal of over 600 scripts written by many others (including many from you)
Option Explicit
Sub Macro1()
'http://www.mrexcel.com/forum/showthread.php?t=578536
Dim wrkSheet As Worksheet
Dim strConsSheet As String
Dim lngOutputRowNum As Long
Application.ScreenUpdating = False
strConsSheet = ActiveSheet.Name
For Each wrkSheet In ThisWorkbook.Sheets
If wrkSheet.Name <> strConsSheet Then
If WorksheetFunction.CountA(Sheets(strConsSheet).Cells) = 0 Then
lngOutputRowNum = 2 'Defualt row number if there's no data on the 'strConsSheet'. Change to suit.
Else
lngOutputRowNum = Sheets(strConsSheet).Range("A:D").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
End If
With Sheets(strConsSheet).Range("B" & lngOutputRowNum & ":D" & lngOutputRowNum)
If InStr(wrkSheet.Name, " ") = 0 Then
.Formula = "=" & wrkSheet.Name & "!U$7"
Else
.Formula = "='" & wrkSheet.Name & "'!U$7"
End If
'.Value = .Value 'Convert links to a values. Uncomment if required.
End With
Sheets(strConsSheet).Range("A" & lngOutputRowNum).Value = wrkSheet.Name
End If
Next wrkSheet
Application.ScreenUpdating = True
End Sub