Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Having trouble importing CSV files with a macro

Hi all,

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

When I open the CSV file i'm using it populates it correctly, but a
soon as I use the macro some of the cells end up being merged into on
cell. Am i using the correct datatype for CSV? If so, has anyone go
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,

Lia

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Having trouble importing CSV files with a macro

Why don't you simply open the csv file and let Excel do all the work

Workbooks.Open Filename:=sImportFile
  #3   Report Post  
Posted to microsoft.public.excel.programming
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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Having trouble importing CSV files with a macro

Liam

I am using this to import a tabed file in to excel (windows)

Workbooks.OpenText FileName:= _
strfilename, Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True,
Comma:=False, _
Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1),
Array(2, 1), Array( _
3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1))

Do not know about a mac system, buy look at the DataType, which can be
set to Mac, and the TextQulifier, ie xlcomma,

It might be easyiest to import one by hand and recored the output
using the macro recorder

Good luck
Ross
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Having trouble importing CSV files with a macro

Thanks for the reply guys

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing and merging Excel files by using a macro ericlbt Excel Discussion (Misc queries) 4 May 6th 09 06:59 PM
Macro for importing text files but the file name changes CHARI Excel Worksheet Functions 3 February 27th 09 08:31 PM
trouble with pxl files Merton Excel Discussion (Misc queries) 1 October 22nd 06 08:34 AM
importing from notepad trouble left_blank Excel Discussion (Misc queries) 3 May 6th 06 02:17 AM
Having trouble with web query, importing not consistent. Mitch Excel Discussion (Misc queries) 0 January 15th 06 06:15 PM


All times are GMT +1. The time now is 08:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"