deleting specified worsheet from code


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: deleting specified worsheet from code

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Posts
    32

    deleting specified worsheet from code

    i am having total of 4 sheets of which sheet 1 & sheet 4 r compulsory
    i am using datatable to fill the sheet with data
    if dt1.rows.count<>0
    -- write data to excel cells
    else
    oWB1.Application.DisplayAlerts = False
    oWB1.Sheets("ABC").Delete
    oWB1.Application.DisplayAlerts = True
    end if

    if dt2.rows.count<>0
    -- write data to excel cells
    else
    oWB1.Application.DisplayAlerts = False
    oWB1.Sheets("XYZ").Delete
    oWB1.Application.DisplayAlerts = True
    end if

    i get error when it goes to else part of dt1 ie on the line
    oWB1.Sheets("ABC").Delete

    but if dt2 count is 0 the else part gets executed sucessfully ie the sheet 3 gets deleted

    error
    Public member 'Worksheets' on type 'Worksheet' not found

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    The last error is occuring because you don't have a variable defined As Worksheet

    What is the error you are getting on oWB1.Sheets("ABC").Delete
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. deleting pointers
    By ami in forum C++
    Replies: 4
    Last Post: 06-02-2008, 08:30 AM
  2. Deleting a tab
    By Laurel in forum VB Classic
    Replies: 3
    Last Post: 02-08-2005, 12:17 PM
  3. Deleting all records through code
    By anonymous in forum VB Classic
    Replies: 4
    Last Post: 02-08-2004, 05:58 AM
  4. Deleting
    By Ricky in forum VB Classic
    Replies: 1
    Last Post: 04-20-2000, 09:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center