CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2001
    Posts
    67

    delete an entry in excel

    How do I delete a row of entry in excel using visual basic?
    Is there also any way I can perform a search on my excel data-base using the excel object?
    Thanx


  2. #2
    Join Date
    Mar 2001
    Location
    Australia
    Posts
    146

    Re: delete an entry in excel

    The following is an example of how to use the find method of excel and how to delete a row:



    Dim xlApp as new Excel.Application
    Dim xlWorkbook as Excel.Workbook
    Dim xlSheet as Excel.Worksheet
    Dim xlRange as Excel.Range

    xlApp.Visible = true

    set xlWorkbook = xlApp.Workbooks.Add

    set xlSheet = xlWorkbook.Sheets(1)

    xlSheet.Cells(9, 4) = "Hello"

    set xlRange = xlSheet.UsedRange.Find(What:="Hello")

    If Not xlRange is nothing then
    xlRange.Delete Shift:=xlUp
    End If

    xlWorkbook.Close false

    xlApp.Quit




    Hope this helps,

    Nathan Liebke


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured