Use nested with statement
Sub NewWorkbook4()
Dim myWorkbook As Workbook, myWorksheet As Worksheet
Set myWorkbook = Workbooks.Add
With myWorkbook
Set myWorksheet = .Worksheets.Add(After:=.Sheets(.Sheets.Count))
With myWorksheet
.Name = "January"
.Range("A1").Value = "Sales Data"
End With
.SaveAs Filename:="JanSales.xls"
End With
End Sub
Related examples in the same category