Possible to calculate from a cell?

J

JAnderson

I'm very familiar with Excel, but not very much with Word and its Merge fields.

I want to use a calculated value in several places, based on the contents of
merge fields. Example:

Subtotal: (Merge field A)
Tax: (Merge field B)
Shipping: (Merge field C)
TOTAL: (SUM of all 3 fields)

So, the question is whether I can have a cell where I can sum all 3 fields,
and whether I can reference that "TOTAL" field in another few places in the
document (rather than recalculating each time).

Thanks for any suggestions!
 
D

Doug Robbins - Word MVP

Use the formula

{ = { MERGEFIELD A } + { MERGEFIELD B } + { MERGEFIELD C } }

You must use Ctrl+F9 to insert each pair of field delimiters { }, and you
may also want to add a formatted switch.

See "Formatting Word fields with switches" on fellow MVP Graham Mayor's
website at

http://www.gmayor.com/formatting_word_fields.htm


--
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
 
J

JAnderson

That makes sense, thank you. Now, what if each Merge field is itself
determined by an if statement? Here's a simplified example ignoring
formatting for now (also, is it required to end formatting switches with "\*
MERGEFORMAT" or is that something Word puts in unnecessarily?):

Subtotal: {if {MERGEFIELD A} = "Widget" "300.00" "150.00"}
Tax: {if {MERGEFIELD B} = "Ohio" "20.00" "0.00"}
Shipping: {if {MERGEFIELD C} = "Ohio" "20.00" "0.00"}

TOTAL: ????? (Normally I would just nest all 3 of the above IF statements,
but there must be a better way).

Any ideas?
 
G

Graham Mayor

How about

{ SET TA { if { MERGEFIELD A } = "Widget" "300.00" "150.00" } }{ SET TB
{ if { MERGEFIELD B } = "Ohio" "20.00" "0.00" } }{ SET TC { if { MERGEFIELD
C } = "Ohio" "20.00" "0.00" } }
Subtotal: { REF TA \# "$,0.00" }
Tax: { REF TB \# "$,0.00" }
Shipping: { REF TC \# "$,0.00" }
TOTAL: { ={REF TA } + { REF TB } + { REF TC } \# "$,0.00" }

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter Jamieson

<<
also, is it required to end formatting switches with "\*
MERGEFORMAT"
No it isn't.

<<
or is that something Word puts in unnecessarily?):
Yes, although I suspect MS thinks inserting it results in a better
experience on average for most users and they may be right.
 

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