Вот как использовать ADODB.
Sub Test()
Dim Ws As Worksheet
Dim sql As String
Dim vFild()
Dim rngFild As Range, rng As Range
Dim strFild As String
Dim n As Integer
Set Ws = Sheets("Output")
With Ws
Set rngFild = .Range("a1", .Range("a1").End(xlToRight))
End With
For Each rng In rngFild
n = n + 1
ReDim Preserve vFild(1 To n)
vFild(n) = "[" & rng & "]"
Next rng
strFild = Join(vFild, ",")
sql = "select " & strFild & "from [Input$] "
exeSQL Ws, sql
End Sub
Sub exeSQL(Ws As Worksheet, strSQL As String)
Dim Rs As Object
Dim strConn As String
Dim i As Integer
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.FullName & ";" & _
"Extended Properties=Excel 12.0;"
Set Rs = CreateObject("ADODB.Recordset")
Rs.Open strSQL, strConn
If Not Rs.EOF Then
With Ws
.Range("a1").CurrentRegion.Offset(1).ClearContents
'For i = 0 To Rs.Fields.Count - 1
' .Cells(1, i + 1).Value = Rs.Fields(i).Name
'Next
.Range("a" & 2).CopyFromRecordset Rs
End With
End If
Rs.Close
Set Rs = Nothing
End Sub