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


Hi there,

I was wondering what I did wrongly.
I wanna run a loop so that it'll import all the .csv files ont
different sheets in a workbook.

What i did is, I put a list of "names" in column A of sheet1, and tol
it to import the files with the SAME "names" from a specific folder
say "c:\comics" . However, I keep getting this error:

RUN-TIME ERROR '1004':
EXCEL CANNOT FIND THE TEXT FILE TO REFRESH THIS EXTERNAL DATA RANGE.
CHECK TO MAKE SURE THE TEXT FILE HAS NOT BEEN MOVED OR RENAMED, THE
TRY THE REFRESH AGAIN

Here's the thing i did:

Dim count As Integer
Dim nama() As String
Dim j As Integer

count = Selection.Rows.count 'counting number of rows with names i
them
ReDim nama(1 To count) 'specifying number of names to count above

For j = 1 To count Step 1

nama(j) = Range("sheet1!A2").Offset(j - 1, 0) 'Assigning names t
variables "nama(j)" from column A of sheet 1

ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add("TEXT;C:\Comics\" & nama(j)
".csv" _
, Destination:=Range("A1"))
...
...
...
.TextFileTrailingMinusNumbers = True
*.Refresh BackgroundQuery:=False*


SO when I run it, it fails.. however, if I change the last line to

With ActiveSheet.QueryTables.Add("TEXT;C:\Comics\Comic1 .csv" _
, Destination:=Range("A1"))


instead of nama(j), it'll run fine... Except that it'll just open 10
new sheets filled with comic1's data.


Any help is appreciated. THanks in advance

--
silves
-----------------------------------------------------------------------
silvest's Profile: http://www.excelforum.com/member.php...fo&userid=1466
View this thread: http://www.excelforum.com/showthread.php?threadid=40133

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to import a .csv file?


*bump* for now


--
silvest
------------------------------------------------------------------------
silvest's Profile: http://www.excelforum.com/member.php...o&userid=14662
View this thread: http://www.excelforum.com/showthread...hreadid=401335

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
Can I import text file of cash flow to excel file then use formula Bumpa Excel Discussion (Misc queries) 2 May 28th 10 04:22 PM
Would Like to Automate Batch File Creation and Text FIle Import socrtwo Excel Discussion (Misc queries) 2 August 18th 06 03:54 PM
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
Import text file into excel with preset file layout, delimeters VBA meldrape Excel Programming 7 June 15th 04 08:31 PM
Get External Data, Import Text File, File name problem Scott Riddle Excel Programming 1 July 11th 03 05:40 PM


All times are GMT +1. The time now is 12:13 AM.

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"