View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Using IF function for 5 variables

Hi Matthew,

Try:
{QUOTE{SET Val {MERGEFIELD Qn_1_Red_4}}{IF{Val}= {=Val} {IF{Val} 10 "U" {IF{Val} 100 "TU" {IF{Val} 1000 "HTU" "Th HTU"}}} {Val}}}
or
{QUOTE{SET Val «Qn_1_Red_4»}{IF{Val}= {=Val} {IF{Val} 10 "U" {IF{Val} 100 "TU" {IF{Val} 1000 "HTU" "Th HTU"}}} {Val}}}

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message. Likwise, you can't type or copy & paste the chevrons (ie '« »') - they're part of the actual mergefields,
which you can insert from the mailmerge toolbar.


--
Cheers
macropod
[Microsoft MVP - Word]


"mj_bowen" wrote in message ...
I am an infant school teacher who has recently stumbled upon the uses of mail
merge. I have limited knowledge of format switches and have found advice on
this forum very clear and useful.

I have looked at; Mail merge - Ask / If function posted on 5/5/2006 6:55 AM
PST

http://www.microsoft.com/communities...e34-4b0c-8aba-
2e17252d39bc&lang=en&cr=us&pt=&catlist=&dglist=&pt list=&exp=&sloc=en-us


The data I have merged results in either a four, three, two, or one digit
number appearing in the word doc. I have been trying to use the IF switch to
add letters before the resulting Mergefield number. For example,

1.If the number is 9 or less than 9 (ie, 9 8 7 6 5 4 3 2 1 0) then a U would
appear before the Mergefield number,eg, U9

2.If the number is between 99 and 10 (including 99 and 10) then a T U would
appear before the Mergefield number, eg, TU21

3.If the number is between 999 and 100 (including 999 and 100) then
H T U would appear before the Mergefield number, eg, HTU354

4.If, the number is between 9999 and 1000 (including 999 and 100) the Th H T
U would appear before the Mergefield number, eg,
Th H T U 3437

5. Finally, the Mergefield may sometimes not result in number being
displayed in the word doc, intead a symbol or a word. This symbol or word
will be displayed on its own - without any Th H T U, H T U, T U or U in front
of it.

I have included an example (probably a very crude one of where I am up to!

{ If Qn_1_Red_410=U{MERGEFIELD Qn_1_Red_4} }
I have been trying to use the IF function, and have managed to come up with
the above code, but am stumped further.

Any advice woud be warmly welcomed.

Matthew