Private Sub Command1_Click() CD1.Filter = "*.xls" CD1.ShowOpen FileName.Text = Trim(CD1.FileName) End Sub Private Sub Submit_Click() FileName = Trim(FileName.Text) BeginValue = Val(Trim(BeginValue.Text)) EndValue = Val(Trim(EndValue.Text)) jg = Val(Trim(jg.Text)) If "" = FileName Then MsgBox "请选择文件" FileName = Trim(CD1.FileName) FileName.Text = Trim(CD1.FileName) Else result = delete(FileName,BeginValue,EndValue,jg) MsgBox "删除成功" End If End Sub Function delete(ByVal FileName As String,ByVal BeginValue As Integer,ByVal EndValue As Integer,ByVal jg As Integer) Dim i As Integer Set x = CreateObject("excel.application") Set xbook = x.Workbooks.Open(FileName) 'Set xsheet = x.Worksheets("sheet1") Set xsheet = x.ActiveSheet For i = BeginValue To EndValue Step jg xsheet.range("A" & i).EntireRow.delete Next i xbook.save xbook.Close delete = 1 End Function
注:间隔删除指定的行
原文链接:https://www.f2er.com/vb/259321.html