#1
|
|||
|
|||
How to setup Nested If statement
I am trying to use a nested If statement on the output of a MailMerge field in Word to set bold for particular text.
The problem is the field text can be one of five options: Never, slight, mild, moderate, severe. What I want is if the text = "moderate" or = "severe" for it to be bold, otherwise not bold. I would be grateful for any help. My Field name is AR. |
#2
|
||||
|
||||
For what you've described, you can do it without nesting:
{IF{MERGEFIELD AR}= "*e" {MERGEFIELD AR \* Charformat} {MERGEFIELD AR}} Note: The field brace pairs (i.e. '{ }') for the above example 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.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
macropod, Thank you for your reply with an interesting solution.
I have now heard from the database guy who informs me there are eight possible options for the field "AR". When I looked at the four that need to be bold, I see they all contain the same sequence of two letters: "er" However, when I amended your syntax the bold did not word: {IF{MERGEFIELD AR}= "*er*" {MERGEFIELD AR \* Charformat} {MERGEFIELD AR}} I looked into this further and one suggestion was that it is not possible to use the wildcard twice which I find unlikely. As an experiment I did try the following, which worked: {IF{MERGEFIELD AR}= "*Severe" {MERGEFIELD AR \* Charformat} {MERGEFIELD AR}} However, when I tried the following the bold did not work: {IF{MERGEFIELD AR}= "*Severe*" {MERGEFIELD AR \* Charformat} {MERGEFIELD AR}} Any further advice would be gratefully received. Am I in the realms of nested If statements? If so, I would appreciate an example. Once again, thank you for your help. |
#4
|
||||
|
||||
Hi bigukfan,
You can't use the * wildcard on both sides of a constant; only before or after. You can use the ? wildcard that way, including in conjuction with the * wildcard on the other side of the constant, but then you have to know exactly how many characters you're dealing with on the ? side of the constant. There's no particular reason I can see from what you've posted for nested IFs. Using the examples from your first post, you could simply have a sequence of IF fields: {IF{MERGEFIELD AR}= "never" {MERGEFIELD AR}}{IF{MERGEFIELD AR}= "slight" {MERGEFIELD AR}}{IF{MERGEFIELD AR}= "moderate" {MERGEFIELD AR \* Charformat}}{IF{MERGEFIELD AR}= "severe" {MERGEFIELD AR \* Charformat}} Nesting is useful where you have multiple conditions that evaluate one way and others that evaluate another way, but you don't want to test them all independently, as per the above, Which could be used thus: {IF{MERGEFIELD AR}= "never" {MERGEFIELD AR} {IF{MERGEFIELD AR}= "slight" {MERGEFIELD AR} {MERGEFIELD AR \* Charformat}}} or if the evaluation of one element is dependent on the evaluation of another (but that typically entails evaluating two mergefields to determine the output).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Macropod, Thanks for your reply, this is now resolved.
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Nested vlookup with varable tables! | Dave Jones | Excel | 0 | 08-30-2012 09:15 AM |
Heading Styles with Nested Numbering | dlowrey | Word | 3 | 02-19-2012 06:48 PM |
numbered nested list | giocarmine | Word | 1 | 01-22-2012 11:19 AM |
Nested IFs | JimS378 | Excel | 7 | 05-03-2011 08:20 PM |
Help with nested cylinders and labels | pixmanlajunta | PowerPoint | 0 | 01-18-2010 11:25 AM |