Share via

Nested IF/THEN with final ELSE

Anonymous
2012-02-03T14:19:32+00:00

I am using Word 2007 on an XP 2002 SP3 machine.  I am merging from Excel into Word using nested IF/THEN statements.  It is working well except if all of the 14 previous values for a section are false, I would like to insert NONE in that section.  I tried using an ELSE but was only able to have it work for the last IF rather than the whole nested IF/THEN.  Thank you for any suggestions you may have. 

-Meghan

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2012-02-03T22:23:28+00:00

    To achieve that, you would need to use proper nested formfields, but there is a limit to how deep they can be nested and I think that limit is less than 14.

    I think therefore that the best way to do this will be to add a new field to the datasource in which you make use of Excel's formula capabilities to populate that field with the appropriate data.

    It is always better to manipulate data in the data source than in the mail merge document.

    --
    Hope this helps.

    Doug Robbins - Word MVP,
    Email: dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2012-02-03T20:53:49+00:00

    Thank you for the clarification and for the links for additional information.

    Here is an example of the problem I am having:

    When all of the values for Plan Sponsor are false (because they are true for Plan Assets), my letter looks like this:

    Fees Paid by the Plan Sponsor

    Fees Paid by the Plan Assets (Direct Compensation)

    Base Fee

    Participant recordkeeping fee for active employees

    Participant recordkeeping fee for terminated employees

    Distribution fee upon termination

    Distribution fee for inservice withdrawals

    Distribution fee for hadship withdrawals

    Distribution fee for required minimum distributions

    Distribution fee for qualified domestic relations order

    Loan processing fee

    I would like to be able to automatically insert NONE directly under the Fees Paid by the Plan Sponsor line if all of the values are false.

    Is this possible?  Thank you.

    Was this answer helpful?

    0 comments No comments
  3. Charles Kenyon 167.7K Reputation points Volunteer Moderator
    2012-02-03T19:18:23+00:00

    OK, these are not nested but rather successive or sequential mergefields. Nested fields are fields inside of fields.

     If none are true in this pattern nothing shows up in the document except a blank line. You can include a line break or paragraph return at the beginning of your truetext to start a new line if there is something to insert. It looks like that is what you are doing.

    If you put the line break at the beginning of your truetext rather than at the end, if none of your conditions are met, you will not have a blank line.

    More on Mail Merge: http://www.addbalance.com/usersguide/mailmerge.htm

    Hope this helps.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-02-03T16:29:13+00:00

    Charles,

    Thank you for the offer to help. 

    I am using mergefields -

    { IF { MERGEFIELD Some_Field 1 } = "True""Some Text 1

    "}{ IF {MERGEFIELD Some_Field 2} = "True""Some Text 2

    "}{ . . .

    I did it this way to avoid a blank line if the value is false.

    I am probably making this much harder than it needs to be.

    Was this answer helpful?

    0 comments No comments
  5. Charles Kenyon 167.7K Reputation points Volunteer Moderator
    2012-02-03T15:51:41+00:00

    Statements (vba) or fields (merge)?

    To troubleshoot your field I would want to actually see it.

    Often nested fields are not needed, successive fields will produce the same result and be far less complex to debug. This is the case when the field is testing one variable or condition. Nested IF fields, are, by their structure, IF/THEN/ELSE.

    Was this answer helpful?

    0 comments No comments