Rounding up on a merged field

W

wmannod

Hi I have the decimal places down with {mergefield total \#,##0.00} But my
amount to the third decimal place is 2,348.115. How do I get the 5 to round
up. I'm looking for 2348.12 it always rounds down at 5. And give me a total
of 2348.11.

thanks in advance.
 
G

Graham Mayor

Word should produce 2348.12 without interference if you use a switch eg \#
",0.00" but if for some reason I cannot fathom it is not doing so then you
could force the same effect with calculated fields eg

{IF { Mergefield Total \# ".000" } = ".??5" "{ =({ Mergefield Total \#
",0.00" } + .01) \# ",0.00" }" "{Mergefield Total \# ",0.00" }" }

would produce the result you require.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi wmannod,

If your source data actually have more than three decimal places, the
2,348.115 that you see when rounding to three decimal places might really be
2,348.1149 or something such, which would round down to 2,348.11 when
rounded to two decimal places.

Cheers
 
W

wmannod

You are correct. But I don't know why it brings in this number. The figure is
coming from an excel spreedsheet that is the total of two feilds that are two
decimal places. One field is amount, the other is GST, it is a calculated
field (=V2*0.07). When the merge is done it brings in the GST and Total
columms in with 14 decimal places. Can I stop this from happening? Total
field accually reads 2348.11499999999998 in the merge.
 
M

macropod

Hi wmannod,

The 2348.11499999999998 is a by-product of how Excel does its rounding.

You can work around this by embedding your mergefield inside a formula
field, coded like:
{={mergefield total \# 0.000} \# ,0.00}
This will round your 2348.11499999999998 to 2,348.12.

Cheers
 
W

wmannod

Thanks,

But everytime I try this I get a syntax error. I've tried in a fomula and
also the toggle field code and just typing it in. I'm using XP and office
2003. Is there a book I can read that has examples of these codes?
 
D

Doug Robbins - Word MVP

Are you using Ctrl+F9 to insert each pair of field delimiters { }?

It certainly does work in Word 2003 running under Windows XP

To see more than you wanted to know about field codes, see macropod's Word
Field Maths 'tutorial', at:

http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top