|
Dim oApp As Object
Dim str As String
Dim oappwork As Workbook
Dim oappwork_sheet1 As Worksheet
Dim j As Integer
Dim rs As New ADODB.Recordset
str = CurrentProject.Path & "\报表\摸板\电子申报交费清册.xls"
Set oApp = CreateObject("Excel.Application")
oApp.Visible = False
If Dir(str) = "" Then
MsgBox "摸板文件丢失,无法倒出!", 16, "错误"
Exit Sub
End If
Set oappwork = oApp.Workbooks.Open(str)
Set oappwork_sheet1 = oappwork.Worksheets("sheet1")
str = "select * from 电子申报查询"
Set rs = GetRS(str)
j = 5
Do While Not IsNull(oappwork_sheet1.Cells(j, 2)) and oappwork_sheet1.Cells(j, 2)) <>""
rs.MoveFirst
rs.Find "企业名称='" & oappwork_sheet1.Cells(j, 2) & "'"
If Not rs.EOF Then
oappwork_sheet1.Cells(j, 6) = CStr(13 - Int(Month(CDate(rs(3)))))
End If
j = j + 1
Loop
oApp.Visible = True
在access查询表中查找excel已有的记录,修改其中相应的数据。。。
这段代码执行效率很差,要过很长时间才能显示出结果。。。
哪位高手能帮我看看,怎样写才能效率高些。。 |
|