Macro variable based on cell contents
Posted on 2013-09-28
I'm importing text files into Excel.
The file name I'm importing is listed in column A.
I need that file name to change, based on which cell I'm on, when running this macro.
The path "C:\Users\JPowell..... (always remains the same)
I recorded this simple sample below.
The next cell would contain something like "Blueberry Crumb".
I need the macro to pull that file name from the corresponding cell", based on where I run the macro. (i.e. my current row position)
' Macro3 Macro
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\JPowell\Desktop\TXT\APPLE CRUMB HORN.txt", Destination:=Range( _
.Name = "APPLE CRUMB HORN"
.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 = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True