Dim xlSheets As Excel.Sheets Set xlSheets = xlBook.Sheets
Dim selSheets As Excel.Sheets Set selSheets = xlSheets.Item(prSheet)
If xlSheets.Count > 1 Then Dim xlSheet As Object Dim n As Integer For n = selSheets.Count To 1 Step -1 Set xlSheet = selSheets.Item(n) Dim xlFirstSheet As Object Set xlFirstSheet = xlSheets.Item(1) If Not xlSheet Is xlFirstSheet Then xlSheet.Move Before:=xlFirstSheet End If Next End If
xlApp.SheetsInNewWorkbook = 1 Dim newBook As Excel.Workbook Set newBook = xlApp.Workbooks.Add() Dim newSheets As Excel.Sheets Set newSheets = newBook.Sheets Dim firstSheet As Excel.Worksheet Set firstSheet = newSheets(1) Dim dstSheet As Object Set dstSheet = firstSheet dstSheet.Name = vbTab Dim srcSheet As Object For Each srcSheet In selSheets srcSheet.Copy After:=dstSheet Set dstSheet = newSheets(newSheets.Count) Next firstSheet.Delete