Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Importing text files using macro

Hello:
I have recorded a macro in Excel that imports a text file into Excel - so
Data Get External Data Import Text File and then follow the wizard. How
can I import another file using the same macro without having to go over the
same steps..i.e using the wizard, etc.
Thanks,
Jade.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Importing text files using macro

can you answer a few questions?

are the filenames always going to be the same?
are they going to be imported to the same sheet, or do you want them on separate
sheets?
i'm guessing the format of the text file is the same.

just change the name of file in the macro you recorded to the new name, if you
just want it on the same sheet

here is some code to get rid of the query if you don't ever want to update the
data

Sub Remove_Query()
For Each sheet In Sheets
i = sheet.Index
For j = Worksheets(i).QueryTables.Count To 1 Step -1
Set MyQT = Worksheets(i).QueryTables(j)
MyQT.Delete
Next
Next
End Sub

--


Gary


"Jade5" wrote in message
...
Hello:
I have recorded a macro in Excel that imports a text file into Excel - so
Data Get External Data Import Text File and then follow the wizard. How
can I import another file using the same macro without having to go over the
same steps..i.e using the wizard, etc.
Thanks,
Jade.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Importing text files using macro

Thanks Gary.
The file names are always going to be different and I want them imported to
the same sheet and sometimes to different sheets.
There are 2 different files text files. One has 16 columns and the other 7.
Multiple files of both kinds will be saved and I just want to use the same
macro to open them in Excel instead of always having to record a macro or go
through the wizard to import each one.
Thanks,
J
"Gary Keramidas" wrote:

can you answer a few questions?

are the filenames always going to be the same?
are they going to be imported to the same sheet, or do you want them on separate
sheets?
i'm guessing the format of the text file is the same.

just change the name of file in the macro you recorded to the new name, if you
just want it on the same sheet

here is some code to get rid of the query if you don't ever want to update the
data

Sub Remove_Query()
For Each sheet In Sheets
i = sheet.Index
For j = Worksheets(i).QueryTables.Count To 1 Step -1
Set MyQT = Worksheets(i).QueryTables(j)
MyQT.Delete
Next
Next
End Sub

--


Gary


"Jade5" wrote in message
...
Hello:
I have recorded a macro in Excel that imports a text file into Excel - so
Data Get External Data Import Text File and then follow the wizard. How
can I import another file using the same macro without having to go over the
same steps..i.e using the wizard, etc.
Thanks,
Jade.




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 for importing text files but the file name changes CHARI Excel Worksheet Functions 3 February 27th 09 08:31 PM
Importing text-files GARY Excel Discussion (Misc queries) 6 December 13th 06 02:57 PM
Importing Text Files smith_gw Excel Discussion (Misc queries) 1 May 5th 05 10:42 PM
Importing text files Dominique Feteau[_2_] Excel Programming 1 December 16th 04 12:25 PM
importing text files msweeney Excel Programming 3 September 24th 03 01:49 AM


All times are GMT +1. The time now is 10:09 PM.

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"