Use this in the worksheet area of your code:
Sub excelforum()
Dim ConT As Object, DataT As Object, constr$, sqlstr$, folder$, getdir
folder = InputBox("Please input the folder location you want to pull the data from." & vbNewLine & vbNewLine & "Syntax: C:\foldername\foldername", "Inputfoldername")
If Right(folder, 1) <> "\" Then folder = folder & "\"
getdir = Dir(folder, vbNormal)
Columns("A:B").ClearContents
Range("A1") = "Filename"
Range("B1") = "AA63 value"
Do Until getdir = ""
If Right(getdir, 4) <> "xlsb" Then GoTo nxtfile
Set ConT = CreateObject("ADODB.Connection")
Set DataT = CreateObject("ADODB.Recordset")
constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & folder & getdir & ";Extended Properties=""Excel 12.0;HDR=No"";"
sqlstr = "SELECT * FROM [" & "FORM" & "$" & "AA63:AA63" & "];"
ConT.Open constr
DataT.Open sqlstr, ConT, 0, 1, 1
If Not DataT.EOF Then
Range("A65536").End(xlUp).Offset(1) = getdir
Range("B65536").End(xlUp).Offset(1).CopyFromRecordset DataT
End If
DataT.Close
Set DataT = Nothing
ConT.Close
Set ConT = Nothing
nxtfile:
getdir = Dir
Loop
End Sub
Works for me.
Bookmarks