Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default macro for import of csv .txt file?

How do I automate the process of importing a CSV .TXT file into an empty
worksheet and placing it in rows and columns in Excel starting in cell A1?
How will the macro select comma and tab delimited and possibly "unicode" text
for Excel 2003 so that my values in the CSV .txt file are put into separate
cells in Excel?

I would like to know how to do this in Excel 2000 and 2003.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default macro for import of csv .txt file?

Here's a sub which will open a file and copy the contenets to a
specified location, then close the file

Sub PlaceFile(sPath As String, CopyTo As Range)

Dim wb As Workbook

Workbooks.OpenText Filename:=sPath, Origin:=437, _
StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Semicolon:=False, Comma:=True
With ActiveWorkbook
.Worksheets(1).UsedRange.Copy CopyTo
.Close False
End With

End Sub


Sub Tester()
PlaceFile "C:\Analysis\tempFile.txt", ActiveSheet.Range("A1")
End Sub


Tim


"Ryan Cain" wrote in message
...
How do I automate the process of importing a CSV .TXT file into an
empty
worksheet and placing it in rows and columns in Excel starting in
cell A1?
How will the macro select comma and tab delimited and possibly
"unicode" text
for Excel 2003 so that my values in the CSV .txt file are put into
separate
cells in Excel?

I would like to know how to do this in Excel 2000 and 2003.



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
macro-import another xls file puiuluipui Excel Discussion (Misc queries) 9 April 1st 10 06:48 PM
Error in large file import macro Scott Calkins via OfficeKB.com Excel Programming 8 September 30th 05 12:39 PM
macro to import file (help with a piece of code) uriel78 Excel Programming 4 March 12th 05 08:36 AM
macro which import alfa*.txt file, how to ? ss_era Excel Programming 1 August 24th 04 01:47 PM
Import text file without specifying a path macro won't work Bruiser Excel Programming 3 January 20th 04 11:47 PM


All times are GMT +1. The time now is 10:35 AM.

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

About Us

"It's about Microsoft Excel"