Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Zero fill, no decimal, need postive/negative sign

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rdraider - 28 Feb 2006 02:05 GMT
Hi all,
I am trying to format a number field so it can be exported to a text file
for import.  I need to format numbers and remove the decimal (if it has
one), zero fill to the left (field is 15 characters) and include a positive
or negative sign on the far right.  The 15th character is the +/- sign.

Examples:
1234.00        should be     00000000123400+
10.25            should be     00000000001025+
12                 should be     00000000001200+
-845.27         should be    00000000084527-

I seem to have the formatting correct except for the +/- sign
I use:    =TEXT(100*F3,"000000000000000")     to get the numbers formatted
The problem is the +/- sign.
I thought about using an adjacent field with:    =IF(F3 > 0,"+","-")
which give me the +/- sign next to the number, which is usable.
My problem with this is with negative numbers (like -845.27).  The field
that contains the re-formatted number (using the =TEXT command above) still
include the negative sign.  So when the 2 cells are put together I get:
00000000-84527-

Any ideas?

Thanks in advance.
Dave Peterson - 28 Feb 2006 02:14 GMT
=TEXT(100*F3,"000000000000000")&IF(F3<0,"-","+")

What happens with 0?

> Hi all,
> I am trying to format a number field so it can be exported to a text file
[quoted text clipped - 21 lines]
>
> Thanks in advance.

Signature

Dave Peterson

rdraider@sbcglobal.net - 28 Feb 2006 19:47 GMT
Thanks Dave,
This is getting closer.  I still get a duplicate negative sign for any
negative amounts.
Example:  -845.27 ends up  -000000000085291-
How can I get rid of the leading negative sign.  I have tried
formatting the source cell various ways but can't quite get it right.

Zero works fine but should never happen here as this is for expense
reports (why submit a zero expense).

Thanks for your help.

> =TEXT(100*F3,"000000000000000")&IF(F3<0,"-","+")
>
[quoted text clipped - 25 lines]
> >
> > Thanks in advance.
Dave Peterson - 28 Feb 2006 19:58 GMT
try:

=TEXT(100*ABS(F3),"000000000000000")&IF(F3<0,"-","+")

> Thanks Dave,
> This is getting closer.  I still get a duplicate negative sign for any
[quoted text clipped - 41 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

rdraider@sbcglobal.net - 28 Feb 2006 21:11 GMT
That works!
Thanks very much, I really appreciate your help.
Have a good day.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.