假设这个使华供参吸艺深训终往EXCEL在桌面上,名字为1.xlsx,数据在A列。编写如下程序
Private Sub Command1_Click()
Dim xlapp As Excel.Application
Dim xlbook As Excel.workbook
Dim xlsht As Excel.Worksheet
Dim i%, r%
Set xlapp = New Excel.Application
xlapp.Visible = True
Set xlbook = xlapp.***.Open("C:\Documents and Settings\admin\桌面\1.xlsx")
Set xlsht = xlbook.Worksheets(1)
r = xlsht.[a65536].End(xlUp).Row
For i = 1 To r
If Cells(i, 1) < Val(Text1) Or Cells(i, 1) > Val(Text2) Then
Cells(i, 1) = A鲁小田适过pplication.WorksheetFunctio搞远岩决省n.Average(Val(Text1), Val(Text2))
Else
End If
Next
End Sub
