Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2018, 05:45 AM
nbuckwheat nbuckwheat is offline IF Statement in Word Windows 8 IF Statement in Word Office 2010 64bit
Novice
IF Statement in Word
 
Join Date: Feb 2018
Posts: 9
nbuckwheat is on a distinguished road
Default IF Statement in Word

Hello, I could use some help please. I have a mail merge template that has a field that references secretaries. I need to replace those secretaries names with their bosses names. We have approximately 20 secretaries.

Is I possible to create an IF statement to do this in Word 2010? An example of what I tried so far and it worked somewhat but it still leaves the secretaries name instead of replacing it with the manager's name, plus I can only do one string . . . and it also changed the font to a smaller font.



{IF "Request_Staff_Person" = "Minnie Mouse" "Mickey Mouse"} The results were: Mickey MouseMinnie Mouse.

Any help would be appreciated.
Reply With Quote
  #2  
Old 02-23-2018, 07:43 AM
gmayor's Avatar
gmayor gmayor is offline IF Statement in Word Windows 10 IF Statement in Word Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You can insert a series of conditional fields (noting the reference to MERGEFIELD
{IF { MERGEFIELD "Request_Staff_Person" } = "Minnie Mouse" "Mickey Mouse"}{IF { MERGEFIELD "Request_Staff_Person" } = "Donald Duck" "Another Mouse"}etc
Use CTRL+F9 for each bracket pair { } and no spaces between the items; but frankly it might be better if you modified the data source to include the appropriate bosses.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 02-23-2018, 08:22 AM
nbuckwheat nbuckwheat is offline IF Statement in Word Windows 8 IF Statement in Word Office 2010 64bit
Novice
IF Statement in Word
 
Join Date: Feb 2018
Posts: 9
nbuckwheat is on a distinguished road
Default

Thank you so much, I'll give this a try. Unfortunately, the managers' names are not in our database, and I don't believe there are plans to add them, the best I could do was to modify the source by adding the available field for the secretaries.

One additional question, is there a limit to how many if statements I can run together?
Reply With Quote
  #4  
Old 02-23-2018, 09:46 AM
nbuckwheat nbuckwheat is offline IF Statement in Word Windows 8 IF Statement in Word Office 2010 64bit
Novice
IF Statement in Word
 
Join Date: Feb 2018
Posts: 9
nbuckwheat is on a distinguished road
Default

This did no work for me.
Reply With Quote
  #5  
Old 02-23-2018, 11:10 AM
Charles Kenyon Charles Kenyon is offline IF Statement in Word Windows 10 IF Statement in Word Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by nbuckwheat View Post
***

One additional question, is there a limit to how many if statements I can run together?
There is no limit to the number of IF Fields you can have, so long as they are independent (not nested, one inside the other).
Reply With Quote
  #6  
Old 02-23-2018, 11:12 AM
Charles Kenyon Charles Kenyon is offline IF Statement in Word Windows 10 IF Statement in Word Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

The structure that Graham set forth is the correct structure. If you want more help, more information than "it didn't work for me" is needed.

Here is more information on the IF Field.
Reply With Quote
  #7  
Old 02-23-2018, 12:07 PM
nbuckwheat nbuckwheat is offline IF Statement in Word Windows 8 IF Statement in Word Office 2010 64bit
Novice
IF Statement in Word
 
Join Date: Feb 2018
Posts: 9
nbuckwheat is on a distinguished road
Default

thanks for the link, i'll try again. a question, I've not done this before in Word. . . didn't even know it was possible. . . I see {MERGEFIELD ....) is this something I would actually type in before I insert the merge field or is it just indicating that the field should be inserted?
Reply With Quote
  #8  
Old 02-23-2018, 01:48 PM
macropod's Avatar
macropod macropod is offline IF Statement in Word Windows 7 64bit IF Statement in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Properly implemented, the field code demonstrated in Graham's post will work. At its simplest, you can use either:
{IF{MERGEFIELD Request_Staff_Person}= "Minnie Mouse" "Mickey Mouse"}{IF{MERGEFIELD Request_Staff_Person}= "Donald Duck" "Another Mouse"}
or:
{IF«Request_Staff_Person»= "Minnie Mouse" "Mickey Mouse"}{IF«Request_Staff_Person»= "Donald Duck" "Another Mouse"}

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, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 02-24-2018, 02:19 PM
nbuckwheat nbuckwheat is offline IF Statement in Word Windows 8 IF Statement in Word Office 2010 64bit
Novice
IF Statement in Word
 
Join Date: Feb 2018
Posts: 9
nbuckwheat is on a distinguished road
Default

My question is geared more to the actual word "MERGEFIELD" when I insert the merge field into the brackets that I've generated by ctrl9, it inserts the merge field but does not include the word MERGEFIELD nor does it include the format with the double arrows as in this example taken from below: «Request_Staff_Person»
Reply With Quote
  #10  
Old 02-24-2018, 02:58 PM
macropod's Avatar
macropod macropod is offline IF Statement in Word Windows 7 64bit IF Statement in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That merely demonstrates the second of the two examples I posted...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 02-24-2018, 03:14 PM
nbuckwheat nbuckwheat is offline IF Statement in Word Windows 8 IF Statement in Word Office 2010 64bit
Novice
IF Statement in Word
 
Join Date: Feb 2018
Posts: 9
nbuckwheat is on a distinguished road
Default

I don't see where my question was answered at all. Thank you anyway.
Reply With Quote
  #12  
Old 02-24-2018, 03:53 PM
macropod's Avatar
macropod macropod is offline IF Statement in Word Windows 7 64bit IF Statement in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Did you actually read my reply???
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 02-24-2018, 04:58 PM
nbuckwheat nbuckwheat is offline IF Statement in Word Windows 8 IF Statement in Word Office 2010 64bit
Novice
IF Statement in Word
 
Join Date: Feb 2018
Posts: 9
nbuckwheat is on a distinguished road
Default

Yes Macropod, I did read your answer; however, I don't believe you read my question . . . I understood what the previous responses were instructing, what I was saying prior to your last response was that no matter what I did . . . the verbiage MERGEFIELD would not appear when I inserted the field into the formula. It only appeared in my result below after I toggled back and forth twice after inserting the field.


For anyone else please that can help with my formula below, I would appreciate it . . .
This is my formula:
{IF{MERGEFIELD Request_Staff_Person}= "Mickey Mouse" "Minnie Mouse"}

This is the result: Mickey Mouse Minnie Mouse. . . instead of replacing Mickey Mouse with Minnie Mouse it is adding it to the same line. I need to replace the original name with the new . . . not add to it.

Many thanks in advance.
Reply With Quote
  #14  
Old 02-24-2018, 08:52 PM
Charles Kenyon Charles Kenyon is offline IF Statement in Word Windows 10 IF Statement in Word Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
My question is geared more to the actual word "MERGEFIELD" when I insert the merge field into the brackets that I've generated by ctrl9, it inserts the merge field but does not include the word MERGEFIELD nor does it include the format with the double arrows as in this example taken from below: «Request_Staff_Person»
If you press Alt+F9 to display field codes, you would see both the MERGEFIELD before the field name. The angle brackets show up when you do not have field codes displayed, instead of the MERGEFIELD and curly brackets.
Reply With Quote
  #15  
Old 02-24-2018, 09:44 PM
gmayor's Avatar
gmayor gmayor is offline IF Statement in Word Windows 10 IF Statement in Word Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

From your description it sounds like you have added the conditional field AFTER the original merge field instead of REPLACING it.

«Request_Staff_Person»{IF{MERGEFIELD Request_Staff_Person}= "Mickey Mouse" "Minnie Mouse"}

The field goes INSIDE the conditional field i.e.

{IF «Request_Staff_Person»= "Mickey Mouse" "Minnie Mouse"}

or with field codes toggled (ALT+F9)

{IF{MERGEFIELD Request_Staff_Person}= "Mickey Mouse" "Minnie Mouse"}
In the case of the latter all bracket pairs are inserted with CTRL+F9

Or you can insert it from the mailmerge tab of the ribbon (Rules)

__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statement in Word IF statement in Word VBA BristolJGM Word VBA 2 09-16-2017 06:02 AM
and if statement in word mailmerge sbye Mail Merge 17 08-25-2017 09:59 PM
VBA Word - Find & Apply Styles to Specific Words - Using Case Statement jc491 Word VBA 17 12-26-2015 12:25 PM
IF Statement in Word Microsoft Word IF statement issues micro44 Word 4 10-23-2014 12:10 PM
Help with IF statement in word 2010 Mad Word 2 04-06-2013 06:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:04 PM.


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