Results 1 to 1 of 1

Delete Sheet

Threaded View

Rose0402 Delete Sheet 03-31-2008, 11:01 AM
  1. #1
    Registered User
    Join Date
    03-28-2008
    Posts
    11

    Delete Sheet

    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
    Last edited by Leith Ross; 03-31-2008 at 11:21 AM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1