excel中用的宏运行,如何速度慢如何解决
我写了段代码,再excel中运行宏,现在运行越来越慢,请各位大神帮助查看下原因Sub 阿新数据导入()
Dim dq As Integer
Dim m As Integer
Dim sq As Integer
Dim n As Integer
Dim wq As Integer
dq = 0
Do Until Sheets("每日收盘价").Range("a" & dq + 1) = ""
dq = dq + 1
Loop
sq = 0
Do Until Sheets("最新导入数据表").Range("a" & sq + 1) = ""
sq = sq + 1
Loop
wq = 0
Do Until Sheets("每日收盘价").Cells(1, wq + 1) = ""
wq = wq + 1
Loop
If wq = 52 Then
Sheets("每日收盘价").Select
Columns("c:g").Select
Selection.Delete Shift:=xlToLeft
MsgBox "数据已经超过10天数据,已经删除最前一天数据!"
wq = 0
Do Until Sheets("每日收盘价").Cells(1, wq + 1) = ""
wq = wq + 1
Loop
End If
Sheets("每日收盘价").Cells(1, wq + 1) = Sheets("参数").Cells(1, 2) & "涨幅"
Sheets("每日收盘价").Cells(1, wq + 2) = Sheets("参数").Cells(1, 2) & "收盘价"
Sheets("每日收盘价").Cells(1, wq + 3) = Sheets("参数").Cells(1, 2) & "开盘"
Sheets("每日收盘价").Cells(1, wq + 4) = Sheets("参数").Cells(1, 2) & "最高"
Sheets("每日收盘价").Cells(1, wq + 5) = Sheets("参数").Cells(1, 2) & "最低"
For m = 2 To dq
For n = 2 To sq
If Sheets("每日收盘价").Cells(m, 1) = Sheets("最新导入数据表").Cells(n, 1) Then
Sheets("每日收盘价").Cells(m, wq + 1) = Sheets("最新导入数据表").Cells(n, 4)
Sheets("每日收盘价").Cells(m, wq + 2) = Sheets("最新导入数据表").Cells(n, 5)
Sheets("每日收盘价").Cells(m, wq + 3) = Sheets("最新导入数据表").Cells(n, 25)
Sheets("每日收盘价").Cells(m, wq + 4) = Sheets("最新导入数据表").Cells(n, 26)
Sheets("每日收盘价").Cells(m, wq + 5) = Sheets("最新导入数据表").Cells(n, 27)
Exit For
End If
Next n
Next m
MsgBox "新数据导入成功!"
ActiveWorkbook.Save
'ActiveWorkbook.Close
'Set Sheets("每日收盘价") = Nothing
'1.超过10天数据自动删除2.导入时要先设定参数的日子3.导入时要看下导出数据格式是否更新4.导入是表每日收盘价和最新导入数据表间的关系。
End Sub