![]() |
|
|
|
#1
|
||||
|
||||
|
Word fields can't really do any meaningful string testing for parts of a string and are even more limited for string splitting. That said, it would be possible to test whether the field ends with 5%, for example, and vary where the whole of the output for that field goes, accordingly.
So, if your field outputs '£84.00 + VAT @ 20%', or '£84.00 + VAT @ 5%', you could use two fields, to conditionally output the whole field in either column: {IF{MERGEFIELD Amount}= "*20%" {MERGEFIELD Amount}} {IF{MERGEFIELD Amount}= "*5%" {MERGEFIELD Amount}} or: {IF«Amount»= "*20%" «Amount}} {IF«Amount»= "*5%" «Amount}} where 'Amount' is your mergefield's name Splitting the output components is more complicated, involving some circumlocution. The following will return the £ values: {IF{MERGEFIELD Amount}= "*20%" {={MERGEFIELD Amount}-.2 \# "£,0.00"}} {IF{MERGEFIELD Amount}= "*5%" {={MERGEFIELD Amount}-.05 \# "£,0.00"}} or: {IF«Amount»= "*20%" {=«Amount»-.2 \# "£,0.00"}} {IF«Amount»= "*5%" «Amount»-.05 \# "£,0.00"}} The following will return the % portions: {IF{MERGEFIELD Amount}= "*20%" "+ VAT @ 20%"} {IF{MERGEFIELD Amount}= "*5%" "+ VAT @ 5%"} or: {IF«Amount»= "*20%" "+ VAT @ 20%"} {IF«Amount»= "*5%" "+ VAT @ 5%"} Note: The field brace pairs (i.e. '{ }') for the above examples are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues. Likewise, you can't type or copy & paste the chevrons (i.e. '« »') - they're part of the actual mergefields, which you can insert from the mailmerge toolbar. The spaces represented in the field constructions are all required.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Perfect that has resolved the problem. Thanks for your help.
|
|
| Tags |
| mergefields, ms word, tables |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Tiered Fee Calculations
|
lynchbro | Excel | 5 | 07-17-2014 11:01 AM |
Table Calculations, VBA
|
SuzeG | Word VBA | 7 | 12-15-2013 07:12 PM |
| How to do Calculations In a Text Box? | SteveF | Word | 4 | 09-27-2013 08:34 AM |
Using Reference Tables in calculations
|
BritBiker2 | Excel | 5 | 02-15-2013 04:19 AM |
Can I do calculations with times?
|
cubsfan_1 | Excel | 1 | 01-14-2010 06:55 PM |