Option Explicit
Dim ShList As Variant
Sub CreateTempSheets()
Dim cartNo As Integer
Dim labelName As String
Dim i As Integer
Dim intSheet As Integer
Dim arSheets() As String
Dim intArrayIndex As Integer
Application.ScreenUpdating = False
intArrayIndex = 0
labelName = "Z:\AllLabelsInOnePDF.pdf"
For cartNo = 1 To 100 Step 2
Sheets("template").Select ' if your sheet with labels named differently, change its name here
Sheets("template").Copy After:=Sheets(Worksheets.Count) 'and here
Sheets("template (2)").Select 'and here
Sheets("template (2)").Name = "S" & cartNo 'and here :-)
Sheets("S" & cartNo).Range("B9").Value = cartNo
Sheets("S" & cartNo).Range("B24").Value = cartNo + 1
ReDim Preserve arSheets(intArrayIndex)
arSheets(intArrayIndex) = Sheets("S" & cartNo).Name
intArrayIndex = intArrayIndex + 1
Next cartNo
Sheets(arSheets).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=labelName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Application.DisplayAlerts = False
Sheets(arSheets).Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub