My file path (\\cat04\PAT\PROD\CAT\STUCT\In\CEE\) does not change, but the file name will change daily.
The tab labeled Main (a8 in this case has 11-17-2017) will have the date that I would like to pull.
The current code written below will try to find \\cat04\PAT\PROD\CAT\STUCT\In\CEE\CAL_BALSUM\20171117_D_3.3_20171117_.txt
But what I need the code to pull is \\[URL="file://cat04/PAT/PROD/CAT/STUCT/In/CEE/"]cat04\PAT\PROD\CAT\STUCT\In\CEE\CAL_BALSUM\20171117_D_3.3_20171117_######.txt[/URL] The # signs indicates a 6 digit random number that will change daily.
Private Const strPath As String = "\\cat04\PAT\PROD\CAT\STUCT\In\CEE\"
Private Const lngHeader As Long = 2
Sub Balance_Summary()
Dim strFileName As String
With wksData
.Range(.Cells(lngHeader, 1), .Cells(.Rows.Count, .Columns.Count)).Clear
strFileName = "CAL_BALSUM_" & Format(ThisWorkbook.Worksheets("main").Range("B8"), "yyyymmdd") & "_D_3.3_" & Format(ThisWorkbook.Worksheets("main").Range("B8"), "yyyymmdd") & "_"
With .QueryTables.Add _
(Connection:="TEXT;" & strPath & strFileName & ".txt", _
Destination:=.Cells(lngHeader, 1))
.Name = strFileName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "|"
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End With
End Sub
The tab labeled Main (a8 in this case has 11-17-2017) will have the date that I would like to pull.
The current code written below will try to find \\cat04\PAT\PROD\CAT\STUCT\In\CEE\CAL_BALSUM\20171117_D_3.3_20171117_.txt
But what I need the code to pull is \\[URL="file://cat04/PAT/PROD/CAT/STUCT/In/CEE/"]cat04\PAT\PROD\CAT\STUCT\In\CEE\CAL_BALSUM\20171117_D_3.3_20171117_######.txt[/URL] The # signs indicates a 6 digit random number that will change daily.
Private Const strPath As String = "\\cat04\PAT\PROD\CAT\STUCT\In\CEE\"
Private Const lngHeader As Long = 2
Sub Balance_Summary()
Dim strFileName As String
With wksData
.Range(.Cells(lngHeader, 1), .Cells(.Rows.Count, .Columns.Count)).Clear
strFileName = "CAL_BALSUM_" & Format(ThisWorkbook.Worksheets("main").Range("B8"), "yyyymmdd") & "_D_3.3_" & Format(ThisWorkbook.Worksheets("main").Range("B8"), "yyyymmdd") & "_"
With .QueryTables.Add _
(Connection:="TEXT;" & strPath & strFileName & ".txt", _
Destination:=.Cells(lngHeader, 1))
.Name = strFileName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "|"
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End With
End Sub