deleting specified worksheet from code
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: deleting specified worksheet from code

  1. #1
    Join Date
    Oct 2008
    Posts
    42

    deleting specified worksheet 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
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,961

    Re: deleting specified worksheet from code

    Turn on Messages

    Code:
    oWB1.Application.DisplayAlerts = True
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center