Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Import Dropping Leading Zeroes

I am importing a comma delimited text file into an Excel
worksheet using Excel 97. Even though a field is
represented in the text file as "000234" (i.e. a text
field), it shows in the worksheet as 234.

How can I prevent the leading zeroes from being dropped?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Import Dropping Leading Zeroes

in the text import wizard, in the last dialog, designate that column as Text

--
Regards,
Tom Ogilvy

"Robert" wrote in message
...
I am importing a comma delimited text file into an Excel
worksheet using Excel 97. Even though a field is
represented in the text file as "000234" (i.e. a text
field), it shows in the worksheet as 234.

How can I prevent the leading zeroes from being dropped?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Import Dropping Leading Zeroes

I am using the command:

Workbooks.Open FileToOpen, Format:=2

and not the import wizard.

Robert

-----Original Message-----
in the text import wizard, in the last dialog, designate

that column as Text

--
Regards,
Tom Ogilvy

"Robert" wrote in

message
...
I am importing a comma delimited text file into an Excel
worksheet using Excel 97. Even though a field is
represented in the text file as "000234" (i.e. a text
field), it shows in the worksheet as 234.

How can I prevent the leading zeroes from being dropped?

Thanks



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Import Dropping Leading Zeroes

So use the opentext method and define your columns to meet your
expectations. If the file is named with a .csv extension, then you will
have to rename it to .txt (as an example) before opening it with opentext or
your settings will be ignored.

You can get a good start by turning on the macro recorder, then doing
File=Open and walking through the text import wizard. The macro recorder
will record your settings as arguments to OpenText.

If the file format will be different each time, then you are back to what I
originally suggested. Naturally, you will then have to change the way you
open the file.

--
Regards,
Tom Ogilvy

"Robert" wrote in message
...
I am using the command:

Workbooks.Open FileToOpen, Format:=2

and not the import wizard.

Robert

-----Original Message-----
in the text import wizard, in the last dialog, designate

that column as Text

--
Regards,
Tom Ogilvy

"Robert" wrote in

message
...
I am importing a comma delimited text file into an Excel
worksheet using Excel 97. Even though a field is
represented in the text file as "000234" (i.e. a text
field), it shows in the worksheet as 234.

How can I prevent the leading zeroes from being dropped?

Thanks



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Import Dropping Leading Zeroes

I guess my real question is this:

There are two fields in the import file. One is "00234"
and the other is "00401UCS". The second field does not
drop the leading zeroes but the first one does.

They both go into the same column on the worksheet. This
column is defined as general. I would think that any field
that is enclosed with quotes would be assumed to be text.

But it appears that even though there are quotes around
the field, if the field is all numeric, it is assumed to
be numeric.

-----Original Message-----
So use the opentext method and define your columns to

meet your
expectations. If the file is named with a .csv

extension, then you will
have to rename it to .txt (as an example) before opening

it with opentext or
your settings will be ignored.

You can get a good start by turning on the macro

recorder, then doing
File=Open and walking through the text import wizard.

The macro recorder
will record your settings as arguments to OpenText.

If the file format will be different each time, then you

are back to what I
originally suggested. Naturally, you will then have to

change the way you
open the file.

--
Regards,
Tom Ogilvy

"Robert" wrote in message
...
I am using the command:

Workbooks.Open FileToOpen, Format:=2

and not the import wizard.

Robert

-----Original Message-----
in the text import wizard, in the last dialog,

designate
that column as Text

--
Regards,
Tom Ogilvy

"Robert" wrote in

message
...
I am importing a comma delimited text file into an

Excel
worksheet using Excel 97. Even though a field is
represented in the text file as "000234" (i.e. a text
field), it shows in the worksheet as 234.

How can I prevent the leading zeroes from being

dropped?

Thanks


.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Import Dropping Leading Zeroes

Correct about numeric is treated as a number.

--
Regards,
Tom Ogilvy

"Robert" wrote in message
...
I guess my real question is this:

There are two fields in the import file. One is "00234"
and the other is "00401UCS". The second field does not
drop the leading zeroes but the first one does.

They both go into the same column on the worksheet. This
column is defined as general. I would think that any field
that is enclosed with quotes would be assumed to be text.

But it appears that even though there are quotes around
the field, if the field is all numeric, it is assumed to
be numeric.

-----Original Message-----
So use the opentext method and define your columns to

meet your
expectations. If the file is named with a .csv

extension, then you will
have to rename it to .txt (as an example) before opening

it with opentext or
your settings will be ignored.

You can get a good start by turning on the macro

recorder, then doing
File=Open and walking through the text import wizard.

The macro recorder
will record your settings as arguments to OpenText.

If the file format will be different each time, then you

are back to what I
originally suggested. Naturally, you will then have to

change the way you
open the file.

--
Regards,
Tom Ogilvy

"Robert" wrote in message
...
I am using the command:

Workbooks.Open FileToOpen, Format:=2

and not the import wizard.

Robert

-----Original Message-----
in the text import wizard, in the last dialog,

designate
that column as Text

--
Regards,
Tom Ogilvy

"Robert" wrote in
message
...
I am importing a comma delimited text file into an

Excel
worksheet using Excel 97. Even though a field is
represented in the text file as "000234" (i.e. a text
field), it shows in the worksheet as 234.

How can I prevent the leading zeroes from being

dropped?

Thanks


.



.



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
Leading Zero dropping off after export to Excel Tina Hudson Excel Discussion (Misc queries) 3 March 30th 10 08:15 PM
Leading Zeroes Melissa Excel Discussion (Misc queries) 3 October 11th 06 07:38 PM
Converting xls to CSV file - dropping leading 0s vanjohnson Excel Discussion (Misc queries) 1 July 5th 06 07:47 PM
spreadsheet dropping leading zeroes when exporting from SQL Serve. RPurgahn Excel Worksheet Functions 0 June 29th 05 02:08 PM
CSV leading zeroes Tim_nol Excel Discussion (Misc queries) 2 December 28th 04 08:19 PM


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