Re: If "Yes" then "Yes or round as percentage

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi John,

Check you mailmerge data connection type, and make sure it's DDE.

--
Cheers
macropod
[MVP - Microsoft Word]


"John" <John@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:215311AA-9F39-45AB-B481-B6941E7B7D42@xxxxxxxxxxxxxxxx
Revising my response from earlier today:
When I use the merge field without a switch it works fine so long as there is a number as the source data. However, It returns "0" (zero) when the source field states "Yes". This was an issue before I responded earlier but I thought I had fixed it by closing and re-opening the two files.

While trying to implement your and macropod's solutions, I found that it would still return "0" when the source was "Yes". I went back to the simple merge field only to learn it is returning 0 even after closing and re-opening the files.

The "No" and Null scenarios are not possible for my current field. Simplifying the solution for "Yes" or a percentage format may give me the starting point for the next field which does include "No" and nulls.

"Graham Mayor" wrote:

What does the field produce without a switch for each condition?

The Yes, No and possibly the null should reproduce what you have in the field. The only one that seems likely to cause trouble is the percentage field. That being the case, on the face of it you need a nest of conditional fields that test each possible result ie

{ IF{ MERGEFIELD Target } = "Y*" "{ MERGEFIELD Target }"} (Look for words beginning upper case Y i.e. YES or Yes)
{ IF{ MERGEFIELD Target } = "N*" "{ MERGEFIELD Target }"}(Look for words beginning upper case N i.e. NO or No)
{ IF{ MERGEFIELD Target } = "" "" } (Look for Null)
{ IF{ MERGEFIELD Target } = "Anything else" "{ ={ MERGEFIELD Target} * 100 \# "0.0%"}" }

so that would give you:

{ IF{ MERGEFIELD Target } = "Y*" "{ MERGEFIELD Target }" "{ IF{ MERGEFIELD Target } = "N*" "{ MERGEFIELD Target }" "{ IF{ MERGEFIELD Target } = "" "" "{ ={ MERGEFIELD Target} * 100 \# "0.0%"}" }" }" }

Each pair of field brackets is inserted with CTRL+F9.

Switches are covered at http://www.gmayor.com/formatting_word_fields.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




John wrote:
> I am trying to import data from Excel into a Word document via mail
> merge. All data in Excel is derived via a formula. One field
> <<Target>> is giving me trouble because is may be a percentage
> e.g.98.5%, a Yes/No. or Null. I have tried If Then and nothing seems
> to work to get the results I need.
>
> If the value is Yes, then I need it to state Yes, If it is a
> percentage, I need it to format as a percent and round to the 1st
> decimal. If it is null, I need it to state "N/A"
>
>
> Incidentally, I do not understand the merge switch concept and why it
> seems to toggle between three states, then two. Resources for this
> would be appreciated as well.
>
> Thanks



.



Relevant Pages

  • Re: Word 2007 is unacceptable and must be changed
    ... Doug Robbins - Word MVP ... there weren't enough persuading factors to make a version switch. ... plan for a poor take-up of Word 2007. ...
    (microsoft.public.word.newusers)
  • Re: Mail merge by data categories
    ... Graham Mayor - Word MVP ... Word MVP web site http://word.mvps.org ... excel 2007, nor in another machine with excel and word 2003. ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Word Wont Start
    ... User Accounts)? ... any luck if you run Word using the /r switch? ... Herb Tyson MS MVP ... Please respond in the newsgroups so everyone can follow along. ...
    (microsoft.public.word.docmanagement)
  • Re: Styles in Word 2007
    ... Switch to Print Layout view if necessary ... From the Quick Styles gallery apply "No Spacing" ... Microsoft Office MVP ... MVP FAQ site: http://mvps.org/ ...
    (microsoft.public.word.docmanagement)
  • Re: formatting of cross reference in W2007
    ... Graham Mayor - Word MVP ... "Suzanne S. Barnhill" wrote: ... I would end up with all caps again instead of the title case ...
    (microsoft.public.word.docmanagement)