Hello Goldfield,
I have added a little more error checking. Hopefully, this will help us. In the Path you were using A297. Seem to be a error so I changed it to A298.
Sub PullQuarterlyData87520034()
Dim char As String, cols As Variant, fields As Variant
Dim fn As String, cn As Object, rs As Object
Dim Headers As String, Item As Variant, Path As Variant
Dim dstWks As Worksheet, dstRng As Range, Rng As Range
Dim srcFile As String, srcWkb As String, srcWks As String
Const adOpenForwardOnly As Long = 0
Const adLockReadOnly As Long = 1
Const adCmdText As Long = 1
cols = "C,O,AA,AM,AY,BK,BW,CI"
Set dstWks = ThisWorkbook.Worksheets("87520034")
Set dstRng = dstWks.Range("A1")
Path = "S:\OUTGRP\8752\Embargoed_Data\Excel\" & dstWks.Range("A298")
Path = IIf(Right(Path, 1) <> "\", Path & "\", Path)
srcWkb = "87520034.xls"
srcWks = "Data1"
srcFile = Path & srcWkb
If Dir(Path, vbDirectory) = "" Then
MsgBox "The folder '" & Path & "' was Not Found.", vbCritical
Exit Sub
End If
If Dir(srcFile) = "" Then
MsgBox "The workbook '" & srcWkb & "' was Not Found in the folder: " & vbLf & Path, vbCritical
Exit Sub
End If
Set Rng = dstRng
For Each Item In Split(cols, ",")
fields = fields & char & "F" & dstWks.Cells(1, Item).Column
Set Rng = Rng.Offset(0, 1)
char = ","
Next Item
Set Rng = dstRng.Offset(0, 1)
Set Rng = Intersect(Rng, Rng.Offset(1, 1))
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
With cn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Properties("Extended Properties") = "Excel 12.0;HDR=No;"
.Open srcFile
End With
rs.Open "Select " & fields & " From [" & srcWks & "$] ;", cn, adOpenForwardOnly, adLockReadOnly, adCmdText
dstRng.Offset(0, 1).CopyFromRecordset rs
cn.Close
Set cn = Nothing: Set rs = Nothing
With Range("B11:I295")
.NumberFormat = "General"
.Formula = .Value
End With
End Sub
Bookmarks