Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Mail Merge

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-30-2016, 03:48 PM
mawallace mawallace is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Jun 2012
Posts: 6
mawallace is on a distinguished road
Default can you nest OR in an if command

I want a paragraph to display if the field in the source is one of two values. It make sense to have IF test 1 OR test w = 1 then etc etc. Is this possible to use OR AND 3rd and if so what's the correct syntax
Reply With Quote
  #2  
Old 11-30-2016, 08:42 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 15,651
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 behold
Default

The simplest approach is to nest the fields or use independent fields. For example:
{IF«MyField»= "Option1" "Output for Option1 & 2"}{IF«MyField»= "Option2" "Output for Option1 & 2"}
or:
{IF«MyField»<> "Option1" {IF«MyField»= "Option2" "Output when neither Option1 nor Option2" "Output for Option1 & 2"}}
The first is simpler when nothing is to be output when either option is false; the second when there is always an output.

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 practical 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 'Insert Merge Field' dropdown. The spaces represented in the field construction are all required.

That said, there are ways of combining multiple AND and/or OR conditions. To see how to do that and a wide range of other calculations in Word, check out my Microsoft Word Field Maths Tutorial, at:
http://windowssecrets.com/forums/sho...Maths-Tutorial
or:
http://www.gmayor.com/downloads.htm#Third_party
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 12-01-2016, 04:54 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 15,651
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 behold
Default

Cross-posted at: http://windowssecrets.com/forums/sho...-on-mail-merge
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #4  
Old 12-07-2016, 04:37 PM
Charles Kenyon Charles Kenyon is online now Windows 8 Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 4,281
Charles Kenyon is just really niceCharles Kenyon is just really niceCharles Kenyon is just really niceCharles Kenyon is just really nice
Default

It may be more work than you wanted, but you've received the best advice on the way to do what you want from Paul.
Reply With Quote
Reply
Please reply to this thread with any new information or opinions.

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a Command Button dkohnken Word VBA 5 03-18-2015 10:13 PM
Nest IF statements with a text comma inbetween each IF statement AClaborn Excel 2 01-20-2015 12:07 PM
Add Command to Bar neiljsalkind Excel 0 02-03-2012 08:31 AM
Add-In:How to add command right click command bar phang Outlook 0 01-15-2007 02:53 AM
command buttons ronf Excel 0 12-03-2005 06:26 AM


All times are GMT -7. The time now is 06:55 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft