*.csv to *.xls

S

Si

To All the more Intelligent People out there than I. (Thanks for the Input &
Time)

Here's what I'm trying to do.
Build a Macro that opens a specific folder and looks for all *.csv and
allows the individual to select a certain *.csv file and then Import it to
the *.xls Workbook that is running the Macro.
The *.csv file that is being imported already has the information in cells
IE: It looks like a *.xls Have been messing around with this for far to long,
tried building a seperate Macro just to convert the *.csv into a *.xls So
that I can then CopyPaste the Information into the Workbook that I'm trying
to get it into. However it just Saves my Original workbook instead of the
*.csv
Have posted before under "open command" (this is my second post ever)
When I use record (which I do most of the time, and then modify) and the
*.csv file is specified it works fine.
Please Help I know this can be done.

Sub Convert()
'
' Convert Macro
' Macro recorded 29/06/2006 by Si
'

'
ChDir "C:\TEMP"
Application.GetOpenFilename ("text files, *.csv")
ActiveWorkbook.SaveAs Filename:="C:\TEMP\Import This.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub
Sub Import()
'
' Import Macro
' Macro recorded 29/06/2006 by Si
'

'
Workbooks.Open Filename:="C:\TEMP\Import This.xls"
Range("A1:AH19").Select
Selection.Copy
Windows("Excel Workbook.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
End Sub

One Macro would be better but if I could get Individuals to Select *.csv and
the Paste into *.xls that would save on my Workbook size?

Cheers for any Help
 
K

Kaak

To import csv file:

Sheets.Add Type:="C:\FileName.csv"

To Select multiple files:

InputFileArray = Application.GetOpenFilename("CSV Files (*.csv)
*.csv", 1, "Select File(s)", , True)

If Not IsArray(InputFileArray) Then Exit Sub

For i = LBound(InputFileArray) To UBound(InputFileArray)

InsertCSV (InputFileArray(i))

Next
 
S

Si

Took some time but Played with it for quite some time and then I got it!
I then slapped myself for being so dumb.
But heres what I was looking for:
"Workbooks.Open Filename:=Application.GetOpenFilename("text files, *.csv")"
Thanks to those that tried to Help.
Guess I should have stated I was a Newbie and that what I was looking for
was the simplest answer.
 

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