Click to See Complete Forum and Search --> : delete an entry in excel


WeeBeng
April 9th, 2001, 11:53 PM
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

GungaDin
April 10th, 2001, 12:20 AM
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