Import

J

John Sutton

My apologies if this is in the wrong spot, I could find no obvious
place for it.

Is it possible to import a .CSV file into an existing .XLS? I want to
bring the data into a spreadsheet inside a macro, but I don't want to
have to use the file name of the spreadsheet, only the name of the
..CSV file. That way, I can use the same macro no matter what the file
is named.

Another alternative, is there a way to get the name of the spreadsheet
within the VB code, then I could just interrogate the spreadsheet for
it's name, open the .CSV file and then do my copy/paste operation to
get the data where I want it.

John
KBS
 
M

Martin

I'm guessing that you've recorded as a macro the steps of importing the .csv
file and have ended up with a macro step that hardwires the workbook name,
e.g.
..Name = "Book1"
You could change this line as follows to work for whatever workbook happens
to be active:
..Name = ActiveWorkbook.Name

Hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top