Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assemble file path and name in VBA/Excel? 1

Status
Not open for further replies.

maxpi

Technical User
Jan 18, 2001
10
0
0
US
I have a number of files in a directory, C:folios on my hard drive, comma delimited text. Corresponding to each file is a symbol, IBM, INTC, etc., in a cell in an Excel file. The corresponding file names would be IBM_D.csv, INTC_D.csv. How can I have VBA get the symbol from the Excel cell and concatenate the "_D.csv" to it and then open the file? I captured a macro while opening one of the files and tried to rewrite so that it gets the first part of the filename from the cell and concatenates the suffix but all attempts to use that to open the file fail.

Max
 
If name in A1 then

=A1 & "_D.csv"

will give you the file name
so
sub wbOpener
mName = A1 & "_D.csv"
mPath = "c:\Folios\"

Workbooks.Open FileName:= mPath & mName
end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top