求助,如何用VB删除某一行记录
3个回答
展开全部
Private Sub Command2_Click()
Dim xlApp As New Excel.Application '定义EXCEL类
Dim xlBook As New Excel.Workbook '定义工件簿类
Dim xlsheet As New Excel.Worksheet '定义工作表类
xlApp.Visible = True '设置EXCEL可见
Set xlBook = xlApp.Workbooks.Open("d:\book1.xls")
Set xlsheet = xlBook.Worksheets(1)
For i = 1 To 9700
For j = 2 To 4
xlsheet.Rows(i).Delete 'Shift:=xlUp '删除第2行就是"2:2",删除1-3行就是"1:3"
Next
Next
End Sub
Dim xlApp As New Excel.Application '定义EXCEL类
Dim xlBook As New Excel.Workbook '定义工件簿类
Dim xlsheet As New Excel.Worksheet '定义工作表类
xlApp.Visible = True '设置EXCEL可见
Set xlBook = xlApp.Workbooks.Open("d:\book1.xls")
Set xlsheet = xlBook.Worksheets(1)
For i = 1 To 9700
For j = 2 To 4
xlsheet.Rows(i).Delete 'Shift:=xlUp '删除第2行就是"2:2",删除1-3行就是"1:3"
Next
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询