Possible Duplicate:
Excel - VBA Question. Need to access data from all excel files in a directory without opening the files
So I've been trying to put together the code people have been sending me and this is what I've got so far...
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
Since I'm not that familiar with this type of code I didn't change much from what people supplied me but I'm hoping it makes some sense together. The problem seems to be that the loop won't stop and it isn't outputting anything either.