所以都會連續使用
on error resume next
........
err.clear
on error goto 0
的方式來強制忽略錯誤後
避免後方又出錯沒找到問題
在當程序的量大到一定程度 這是必用上的技術
另外當 有時候on error resume next 後
遇到錯誤 就必須歸零 避免程序又錯
例如
on error resume next
in isobect(ar) then err.clear:on error go to 0 :exit sub
err.clear:on error go to 0
...
...作者: av8d 時間: 2023-12-12 22:01
Dim FNcell As Range
For Each Z In FNwb.Sheets(FNTD).Range("C2:CM2")
If Z.Value = Int(Format((DateValue(CB)), 0)) Then
Set FNcell = Z
Exit For
End If
Next
If Not FNcell Is Nothing Then
FNcell.Offset(1, 0).Select
For m = 7 To 12
For n = 1 To 4
ActiveCell.Offset(m, n - 1) = Cells(m + 5, n * 2)
Next
Next
For m = 19 To 24
For n = 1 To 4
ActiveCell.Offset(m, n - 1) = Cells(m, n * 2)
Next
Next
ActiveCell.Offset(-1, 0).Select
'更新[歷史合計]
Dim i As Integer, j As Integer
'當日合計貼到歷史合計B4:B9
For i = 4 To 9
Cells(i, 2) = Cells(i + 8, 4)
Next
'當日合計貼到歷史合計D4:D9
For i = 4 To 9
Cells(i, 4) = Cells(i + 8, 8)
Next
'當日合計貼到歷史合計F4:F9
For i = 4 To 9
Cells(i, 6) = Cells(i + 15, 4)
Next
'當日合計貼到歷史合計H4:H9
For i = 4 To 9
Cells(i, 8) = Cells(i + 15, 8)
Next
'清除[當日合計]
For i = 2 To 8 Step 2
For j = 12 To 17
Cells(j, i) = ""
Next
Next
For i = 2 To 8 Step 2
For j = 19 To 24
Cells(j, i) = ""
Next
Next
[K3:O15].ClearContents
[J20].ClearContents
Else
MsgBox "在【市民卡日報表】中找不到 " & CB & " ,動作終止。"
End If