Hi, everyone.
How can i delete a entire row in the excell via VB?
Thanks.
Printable View
Hi, everyone.
How can i delete a entire row in the excell via VB?
Thanks.
Use the Delete method for the EntrieRow property of a range.
VB Code:
Sub DeleteRow() Dim rngSingleCell As Range Set rngSingleCell = Worksheets(1).Range("C5") rngSingleCell.EntireRow.Delete End Sub
From VB 6...
VB Code:
Option Explicit 'Add a reference to MS Excel xx.0 Object Library Private Sub Command1_Click() Dim oApp As Excel.Application Dim oWB As Excel.Workbook Set oApp = New Excel.Application Set oWB = oApp.Workbooks.Open("C:\Test.xls") 'Delete the entire row 5 oWB.Sheets("Sheet1").Rows(5).Delete oWB.Close SaveChanges:=True, Filename:="C:\Test.xls" Set oWB = Nothing oApp.Quit Set oApp = Nothing End Sub