I am using the following code to create an excel sheet:
Which works fine. However, I need more than one sheet to be created. I have tried changing the Excel.Sheet object variable to various other things (including workbook, ect) but they all don't work.
Any ideas how to get more than 1 sheet to be created in the same document?
Thanks!
Code:
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible = True
ExcelSheet.Application.Cells(1, 1).Value = "Customer"
ExcelSheet.Application.Cells(1, 2).Value = [CustomerName]
'Again repeated lots of times for various different values
ExcelSheet.Application.ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ExcelSheet.SaveAs mdrive & mdir & "\" & [CustomerName] & "\" & [JobSiteName] & " - " & [JobNumber] & "\a. Site Details\SiteDetails.xlsx"
ExcelSheet.Application.Quit
Set ExcelSheet = Nothing
Any ideas how to get more than 1 sheet to be created in the same document?
Thanks!
Comment