Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Leading zeros in Excel

I have Excel 2007 worksheet. Besides other data, it contains productnumbers
(10 digits). Some of this product # begin with 0. The sheet is formatted as
General.

This sheet is used as an input into another app which can not take text as
format.

Does anyone know how do I format product # so that leading zeros are
preserved? I tried it as "@" and "0000000000" and in Excel it looks like
there is a leading zero, it is just formatting and gets dropped in the other
app.

How do I do this? I am creating this worksheet using VBA.

Thanks much.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Leading zeros in Excel

If you use a numberformat of Text (or "@" in code), then whatever you plop into
that cell will be kept. If you want leading 0's, you'll have to put them there
yourself.

Dim myNum As Long
myNum = 1234
With ActiveCell
.NumberFormat = "@"
.Value = Right(Format(myNum, String(10, "0")), 10)
End With



omsoft wrote:

I have Excel 2007 worksheet. Besides other data, it contains productnumbers
(10 digits). Some of this product # begin with 0. The sheet is formatted as
General.

This sheet is used as an input into another app which can not take text as
format.

Does anyone know how do I format product # so that leading zeros are
preserved? I tried it as "@" and "0000000000" and in Excel it looks like
there is a leading zero, it is just formatting and gets dropped in the other
app.

How do I do this? I am creating this worksheet using VBA.

Thanks much.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Leading zeros in Excel

Thanks Dave, the leading zeros are there and I see them. But may be it is the
other system's fault in reading it. But I have to go around it.

In any case, I will try the code that you have below. Thanks for the same.

"Dave Peterson" wrote:

If you use a numberformat of Text (or "@" in code), then whatever you plop into
that cell will be kept. If you want leading 0's, you'll have to put them there
yourself.

Dim myNum As Long
myNum = 1234
With ActiveCell
.NumberFormat = "@"
.Value = Right(Format(myNum, String(10, "0")), 10)
End With



omsoft wrote:

I have Excel 2007 worksheet. Besides other data, it contains productnumbers
(10 digits). Some of this product # begin with 0. The sheet is formatted as
General.

This sheet is used as an input into another app which can not take text as
format.

Does anyone know how do I format product # so that leading zeros are
preserved? I tried it as "@" and "0000000000" and in Excel it looks like
there is a leading zero, it is just formatting and gets dropped in the other
app.

How do I do this? I am creating this worksheet using VBA.

Thanks much.


--

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
Excel Leading Zeros Brandy Excel Discussion (Misc queries) 3 October 1st 07 07:20 PM
Importing to Excel from csv AND keep leading zeros Ken Excel Discussion (Misc queries) 2 September 29th 06 07:15 PM
Excel Leading Zeros [email protected] Excel Discussion (Misc queries) 3 January 17th 06 06:59 PM
leading zeros in excel kiwi Excel Discussion (Misc queries) 3 May 17th 05 06:59 PM
save text field w/ leading zeros in .csv format & not lose zeros? Ques Excel Discussion (Misc queries) 1 May 4th 05 06:21 PM


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