【发布时间】:2017-05-07 20:48:58
【问题描述】:
我有以下代码返回文件夹中的文件数。
Sub sample()
Dim FolderPath As String, path As String, count As Integer
FolderPath = "C:\Documents and Settings\Santosh\Desktop"
path = FolderPath & "\*.xls"
Filename = Dir(path)
Do While Filename <> ""
count = count + 1
Filename = Dir()
Loop
Range("Q8").Value = count
'MsgBox count & " : files found in folder"
End Sub
我需要将 FolderPath 参数化为 Excel 工作表本身的输入,以便在单元格 A1 中输入文件夹路径并获取 B1 中的文件数。我对 Excel 宏很陌生 - 如果这是非常基本的,请原谅。我该怎么做?
【问题讨论】: