View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How to fill a sheet in Excel2003 with CSV data?

The closest you could come is to get the string in the clipboard and then
paste it to the sheet into cell A1 (as an example). This should put all the
data in column A, then you could use the Text to Columns Method under the
Data menu to parse your data into the appropriate columns.

put some data in A1 and A2 like below

123,"abc",345,"cdef","ghij",456
"iii",31111,"rst",1,"mnop",,345

Then turn on the macro recorder

select A1:A2

then do
Data=Text to Columns
Choose delimited and Next
Choose Comma as the separator (if that is your separator)
Then click finish
Turn off the macro recorder

This produces:

Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited,
_
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=False, _
Semicolon:=False, Comma:=True, 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))

So once you put your string in column 1, you can run this and it should do
the equivalent of opening a csv file.

(change selection to something like
Activesheet.Range("A1").CurrentRegion.TextToColumn s . . .

--
Regards,
Tom Ogilvy



"tmarko" wrote in message
...

Hi Tom Ogilvy!

I cannot get your code working. The spreadsheet info is not important
after all just info why I pass CSV data to the Client.

I want to populate an Excelsheet with CSV data from this string as fast
as possible (Excel2003). I was hoping for a property that is found in
Worksheet or something to fill the sheet. Instead of looping through
the file beacuse when open up a .SCV file everything seems to go by
magic. But I do not want to involve a file in my application.

Thanks anyway


tmarko
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message345904.html