Private Sub Command1_Click() Dim sFile As String With CommonDialog1 .DialogTitle = "open" .CancelError = False .Filter = "EXCEL文件(*.xls)|*.xls|所有文件 (*.*)|*.*" .ShowOpen If Len(.FileName) = 0 Then Exit Sub End If sFile = .FileName End With
Dim mx As Integer
Dim yx
Dim excelApp As Excel.Application Set excelApp = New Excel.Application excelApp.Workbooks.Open FileName:=sFile 'xlApp.Visible = True excelApp.Worksheets(2).Activate mx = excelApp.Cells(9, 5) Text1.Text = mx excelApp.Workbooks.Close excelApp.Quit Set excelApp = Nothing
End Sub可以将第一个按钮里的代码写成自定义函数. 清数据: excelApp.sheets(2).cells(6,3).clearcontents excelApp.Worksheets(2).Range("C6").Delete 谢谢ls的 那如果要删除该行第六列之后的所有内容该怎么写循环呢?