Microsoft Office Forums How to setup Nested If statement

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-22-2014, 08:25 AM
bigukfan bigukfan is offline How to setup Nested If statement Windows 8 How to setup Nested If statement Office 2010 32bit
Novice
How to setup Nested If statement
 
Join Date: Mar 2014
Location: England
Posts: 9
bigukfan is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 04-23-2014, 02:33 AM
macropod's Avatar
macropod macropod is offline How to setup Nested If statement Windows 7 32bit How to setup Nested If statement Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

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
[MS MVP - Word]
Reply With Quote
  #3  
Old 04-23-2014, 05:34 AM
bigukfan bigukfan is offline How to setup Nested If statement Windows 8 How to setup Nested If statement Office 2010 32bit
Novice
How to setup Nested If statement
 
Join Date: Mar 2014
Location: England
Posts: 9
bigukfan is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 04-23-2014, 02:47 PM
macropod's Avatar
macropod macropod is offline How to setup Nested If statement Windows 7 32bit How to setup Nested If statement Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

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
[MS MVP - Word]
Reply With Quote
  #5  
Old 04-30-2014, 05:19 AM
bigukfan bigukfan is offline How to setup Nested If statement Windows 8 How to setup Nested If statement Office 2010 32bit
Novice
How to setup Nested If statement
 
Join Date: Mar 2014
Location: England
Posts: 9
bigukfan is on a distinguished road
Default

Macropod, Thanks for your reply, this is now resolved.
Reply With Quote
Reply

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
How to setup Nested If statement numbered nested list giocarmine Word 1 01-22-2012 11:19 AM
How to setup Nested If statement 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


All times are GMT -7. The time now is 10:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft