|
介绍一下下面代码,我的宏代码运行表格点击按钮会打开指定路劲下面的excel文件,然后写入数据到这个激活excel文件里面然后在关闭保存这个打开的excel文件,我代码里面有3次这种操作,我下面只复制了打开一个文件的代码,每次打开文件写入数据就会关闭保存,然后继续打开另外一个文件继续写入数据在关闭保存,但是有几率会在这个保存并关闭打开的excel表格的时候卡死,而且几率性的卡死在三次打开文件的某一次,并不会固定卡死在一个地方。卡死的点是:ActiveWorkbook.Close savechanges:=True
卡死在保存退出
Workbooks.Open Filename:=FeeDestinationFile
Nl = ActiveWorkbook.Sheets(zhandian).[A65536].End(xlUp).Row
qrr = ActiveWorkbook.Sheets(zhandian).Range("A2:A" & Nl)
riqi = Application.Text(Replace(Split(ThisWorkbook.Name, "-")(0), ".", "/"), "yyyy/m/d")
For i = 1 To UBound(qrr)
If qrr(i, 1) <> "" Then
If Application.Text(Split(qrr(i, 1), "-")(0), "yyyy/m/d") = riqi Then
mlogic_row = i
Exit For
End If
End If
Next i
ActiveWorkbook.Sheets(zhandian).Cells((mlogic_row + 1), 5).Resize(UBound(Xiuzheng, 1), UBound(Xiuzheng, 2)).Value = Xiuzheng
N2 = ActiveWorkbook.Sheets(zhandian).[E65536].End(xlUp).Row
ActiveWorkbook.Sheets(zhandian).Cells(N2, 5) = sum_numbers
ActiveWorkbook.Close savechanges:=True
|
|