#1   Report Post  
smith_gw
 
Posts: n/a
Default Importing Text Files

When importing a comma-delimited .txt file, are there any settings that can
be made so that Excel automatically recognizes all leading zeros in fields?
I am now going through the import wizard and changing the format from general
to text for all fields that I can recognize that have leading zeros but this
is cumbersome.
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

No.

But if you're always importing files with the same layout, you could record a
macro when you import one of these files.

Do all the stuff you want during the import, but keep recording when you add
headers/page setup/filters/subtotals/whatever.

Then when you need to open the next file, just rerun the macro.

You could even ask the user (you???) for the name of the file to import:

Option Explicit
Sub testme()

Dim myFileName As Variant

myFileName = Application.GetOpenFilename(filefilter:="Text Files, *.Txt", _
Title:="Pick a File")

If myFileName = False Then
MsgBox "Ok, try later" 'user hit cancel
Exit Sub
End If

Workbooks.OpenText Filename:=myFileName '....rest of recorded code here!

End Sub

You'll have to add all that .opentext stuff from your recorded macro.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

smith_gw wrote:

When importing a comma-delimited .txt file, are there any settings that can
be made so that Excel automatically recognizes all leading zeros in fields?
I am now going through the import wizard and changing the format from general
to text for all fields that I can recognize that have leading zeros but this
is cumbersome.


--

Dave Peterson
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 multiple Text files into Excel 2003 JMA Excel Discussion (Misc queries) 5 May 5th 05 09:48 PM
Importing text files with mathematical characters The Beckster Excel Discussion (Misc queries) 1 March 2nd 05 12:56 PM
importing multiple text files URGENT!!! HELP tasha Excel Worksheet Functions 0 December 19th 04 04:26 PM
importing multiple text files??? tashayu Excel Discussion (Misc queries) 0 December 19th 04 02:43 PM
Importing text files into Excel Christopher Anderson Excel Discussion (Misc queries) 2 December 4th 04 05:57 PM


All times are GMT +1. The time now is 12:55 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"