I have VBA that goes out and opens a txt file and imports the data into Excel. The file name changes every month and in place of updating my code everytime I need to import the file, can I create an input box with a browse button to select the file?? This is what I have:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;I:\Recons\Inv Recon\2011 Inventory Recon\03-11\Uninvoiced_Receipts_Report_030411.txt" _
, Destination:=Range("$A$1"))
.Name = "Uninvoiced_Receipts_Report_030411"
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 1, 9, 1, 1)
.TextFileFixedColumnWidths = Array(65, 20, 5, 20)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Thanks!
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;I:\Recons\Inv Recon\2011 Inventory Recon\03-11\Uninvoiced_Receipts_Report_030411.txt" _
, Destination:=Range("$A$1"))
.Name = "Uninvoiced_Receipts_Report_030411"
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 1, 9, 1, 1)
.TextFileFixedColumnWidths = Array(65, 20, 5, 20)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Thanks!