copy csv worksheet to xls book using vba/vbs

A

anthony.buss

Hello all,

I've been searching the web and posts for almost 4 weeks and can't
seem to find what I need. Please forgive me I'm new to programming
with VBA/VBS.

Basically I have file #1 <file1.csv> which contains a result set
created by another application. What I'd like to do is use a script
to copy the values from sheet1 (or the whole sheet would be fine) into
file #2 <file2.xls> so users can run formulas, vlookups, etc. without
having to access a separate file (and leave the original data
untouched).

Is there an efficient way to do this with vba or vbs? It seems easy
enough but I can't put my finger on it.

Thanks,
-ab
 
T

Trevor Williams

Hi Anthony

Here's a very basic version of what you're looking to do.
With File2.xls open, tt opens the CSV file and copies the data sheet to the
end of the XLS file.

'Change file names and directory name accordingly
Sub CopyCSVdata()
Workbooks.Open Filename:= _
"C:\File1.csv"
Sheets("File1sheet").Copy After:=Workbooks("File2").Sheets.Count
End Sub

HTH
Trevor Williams
 

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