Hello, I am trying to add a new sheet to an active workbook. Below is the code that I am trying to use, but I keep getting a error that reads invalid object.
Set excelReport = CreateObject("Excel.Application")
excelReport.Workbooks.Add
Set excelSheet1 = excelReport.ActiveWorkbook.WorkSheets(1) 'Account Level results
Set busAcctLevelSheet = excelReport.ActiveWorkbook.WorkSheets(2)
Set excelSheet2 = excelReport.ActiveWorkbook.WorkSheets(3)
excelReport.ActiveWorkbook.Add
Set excelSheet3 = excelReport.ActiveWorkbook.WorkSheets(4) 'Not Found Sheet
Set excelReport = CreateObject("Excel.Application")
excelReport.Workbooks.Add
Set excelSheet1 = excelReport.ActiveWorkbook.WorkSheets(1) 'Account Level results
Set busAcctLevelSheet = excelReport.ActiveWorkbook.WorkSheets(2)
Set excelSheet2 = excelReport.ActiveWorkbook.WorkSheets(3)
excelReport.ActiveWorkbook.Add
Set excelSheet3 = excelReport.ActiveWorkbook.WorkSheets(4) 'Not Found Sheet