I am using the code below to export an Excel spreadsheet to a new workbook. I want to use the same file name and update Sheet2 as I will be using a pivot table on Sheet 1. Any other suggestions will be helpful also... I need help with how to:
1. Delete Sheet2 in workbook before adding new data.
Dim strExcelFile As String
Dim strWorksheet As String
Dim strDB As String
Dim strTable As String
Dim objDB As Database
strExcelFile = "C:\Documents and Settings\Desktop\Project\LDMS_Spec.xls"
strWorksheet = "Sheet2"
strDB = "C:\Documents and Settings\Desktop\Employee.mdb"
Set gWorkSpace = DBEngine.Workspaces(0)
Set objDB = gWorkSpace.OpenDatabase("C:\Documents and Settings\Desktop\Employee.mdb")
objDB.Execute _
"SELECT employee.employeename, hiredate.date INTO [Excel 8.0;DATABASE=" & strExcelFile & _
"].[" & strWorksheet & "] FROM table1
objDB.Close
Set objDB = Nothing
Bookmarks