Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.


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. :-)

In reply to Re: Excel - how do I format negative Costs in Red by davies
in thread Excel - how do I format negative Costs in Red by merrymonk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-06-23 04:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.