vb做的excel小软件

前端之家收集整理的这篇文章主要介绍了vb做的excel小软件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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


注:间隔删除指定的行

猜你在找的VB相关文章