-1
可能重複:
Excel - VBA Question. Need to access data from all excel files in a directory without opening the filesExcel的VBA - 試圖從Excel文件的目錄中提取數據,繼續
所以我一直試圖整理人已發送代碼我和這是我到目前爲止...
Dim xcell As Range
Dim ycell As Range
Dim sheetname As String
Dim wbList() As String, wbCount As Integer, i As Integer
Dim wbname As String
FolderName = "\\Drcs8570168\shasad\Test"
wbname = Dir(FolderName & "\" & "*.xls")
While wbname <> ""
Set ycell = Range("a5", "h5")
Set xcell = Range("a2", "h2")
sheetname = "loging form"
ycell.Formula = "=" & "'" & FolderName & "\[" & wbname & "]" _
& sheetname & "'!" & xcell.Address
Wend
End Sub
因爲我不熟悉這個代碼類型我從人們提供給我的東西沒有太大改變,但我希望它們能夠在一起。問題似乎是循環不會停止,也不會輸出任何東西。
對不起,犯了一個錯誤。它確實輸出3行(目錄中只有3個文件),但它們都來自同一個文件,所以它看起來好像沒有向下移動文件列表。 – user960358