reference can be assigned to an object variable so that you can easily refer to the new object in later code : Object Variable Set « Data Type « VBA / Excel / Access / Word
reference can be assigned to an object variable so that you can easily refer to the new object in later code
Sub NewWorkbook()
Dim myWorkbook As Workbook, myWorksheet As Worksheet
Set myWorkbook = Workbooks.add
Set myWorksheet = myWorkbook.Worksheets.add(After:=myWorkbook.Sheets(myWorkbook.Sheets.Count))
myWorksheet.name = "January"
myWorksheet.range("A1").value = "Sales Data"
myWorkbook.SaveAs FileName:="YourExcel2007File.xlsx"
End Sub