Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Excel - how do I format negative Costs in Red

by davies (Monsignor)
on Feb 03, 2010 at 00:06 UTC ( [id://821060]=note: print w/replies, xml ) Need Help??


in reply to Excel - how do I format negative Costs in Red

It's too late at night to go through all your code, but you need something like:
$rng = your range; $rng->{NumberFormat} = "#,##0.00_);[Red] (#,##0.00)"
An Excel format has four parts. I have never needed to know what the fourth does. The first is for positive numbers, the second for negative and the third for zeros. If missing, they default to the format for positive numbers. The string I have given you is one I use frequently, and a variant on my standard format. The underscore after the last zero of part 1 means "leave enough space after the number for the character that follows the underscore". [Red] does what I think you want, but note the space following it. It's critical.

Note also that if you want this as a format for everything rather than a few cells, you are better off using styles.

Regards,

John Davies

P.S. Is this the point at which I suggest a new section in PerlMonks for Excel posts? Everyone else seems to have been suggesting new sections recently. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://821060]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-05-30 01:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found