View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Flanagan Bob Flanagan is offline
external usenet poster
 
Posts: 340
Default Having trouble importing CSV files with a macro

Looks like you must be running additional code that is doing the merging.
There is no statement in what you have posted that would merge the cells.
It may be that all the data is not being read into individusl cells. Stop
the code immediately after reading in the CSV file and expand the columns
and see if the data is not properly read in.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Sportiva " wrote in message
...
Hi all,

I'm having a problem with a small amount of VB code I've written for
use with Excel on my mac (Excel X). I need to prompt the user to select
a particular CSV file, copy it, and paste it into the current worksheet
I'm using.

When I open the CSV file i'm using it populates it correctly, but as
soon as I use the macro some of the cells end up being merged into one
cell. Am i using the correct datatype for CSV? If so, has anyone got
any other ideas as to what might be wrong?

Sub Test()

Dim sImportFile

sImportFile = Application.GetOpenFilename
Workbooks.OpenText FileName:=sImportFile, DataType:=xlDelimited,
Comma:=True
ActiveSheet.UsedRange.Select
Selection.Copy
ActiveWorkbook.Close
Worksheets("Marks and Grades").Range("A1").Activate
ActiveSheet.Paste

End Sub

Thanks a lot in advance,

Liam


---
Message posted from http://www.ExcelForum.com/