Same topic
This code requires the sheet be selected in order for it to run.. How could I run the code without the sheet selected?
does it involve "defining shd and wbD then Set shD = wbD.Sheets("Data4")
I tried it but not certain if I accounted for everything
Code: Select all
Sub CombineAllData4()
Dim shM As Worksheet
Dim Sht As Worksheet
Dim r As Long
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Set shM = Worksheets("Data4")
' Clear the Data sheet
shM.Range("2:" & shM.Rows.Count).ClearContents
For Each Sht In ActiveWorkbook.Worksheets
Select Case Sht.Name
Case "Schedule", "Hours", "Attrition", "Orientation", "Actuals", "ClassDist", "HiringPlan", "Data", "Data2", "Data3", "Data4", "Data5", "Data6"
' Ignore these sheets
Case Else
r = shM.Range("A" & shM.Rows.Count).End(xlUp).Row + 1
shM.Range("A" & r).Resize(82).Value = Sht.Name
' Copy range, then paste values
Sht.Range("E74:BF114").Copy
shM.Range("B" & r).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Sht.Range("E115:BF155").Copy
shM.Range("B" & r + 41).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End Select
Next Sht
Application.CutCopyMode = False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub