我的程式碼如下:
With ActiveSheet
n = .[A65536].End(xlUp).Row + 1
Range(.Cells(4, 1), .Cells(n, 4)).ClearContents
path1 = CStr(.Range("B1")) & "\"
file1 = Dir(path1): r = 1
i = 4
Do While file1 <> ""
.Cells(i, 1) = file1
i = i + 1
r = r + 1
file1 = Dir '取得下一個檔名
Loop
End With
End Sub