Sub test()
Dim mFolder As String
Dim i As Integer
Dim k As Integer
Dim MyDate
MyDate = Date
Range("AD3").Value = MyDate
k = 6
mFolder = ThisWorkbook.Path
[A4] = "路徑"
'[B1] = "檔案名"
With Application.FileSearch
.NewSearch
.LookIn = mFolder
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
If .FoundFiles(i) <> ThisWorkbook.FullName Then
Call Write_In(.FoundFiles(i))
End If
If i Mod 2 = 0 Then
Range("B" & k & ":AD" & k + 1).Select
With Selection.Interior
.ColorIndex = 8
.Pattern = xlSolid
End With
End If
k = k + 2
Next i
Else
MsgBox "檔案夾 " & mFolder & "中沒有所需的檔案"
End If
End With
Range("A4:A80").Clear
End Sub
uj5u.com熱心網友回復:
注釋掉所有On Error Resume Next陳述句,在VBA IDE中運行,出錯后點擊除錯,游標會停在出錯的那條陳述句處,
或者
事先在懷疑可能有邏輯錯誤的陳述句處設定斷點,運行經過斷點時中斷,
此時可以在立即視窗中使用
?變數名
或
?函式名(函式引數)
或
程序名(引數)
輔助除錯。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/46840.html
標籤:VBA
