In general, there is no need to select or activate objects, so a corresponding run-time error is easily avoided in this regard.
Try the code below and see if it does what you want.
Sub SplitWorkbook()
Dim ShtSource As Worksheet, ShtDestination As Worksheet
For Each ShtSource In ThisWorkbook.Worksheets
ShtSource.Copy
Set ShtDestination = ActiveSheet
With ShtDestination.UsedRange
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
Excel.Application.CutCopyMode = False
Excel.Application.Goto Range("A1")
Dim FileName As String
Dim Path As String
Excel.Application.DisplayAlerts = False
Path = "C:\Users\jsmith\OneDrive - Test\Documents\Model\2022 Budget\Partners\"
With ShtDestination
FileName = .Range("A1").Value & ".xlsx"
.Parent.SaveAs Path & FileName, xlOpenXMLWorkbook
.Parent.Close
End With
Excel.Application.DisplayAlerts = True
Next ShtSource
End Sub
Bookmarks