Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word 2010 IF formula to check string contents

    Hi all, I have a Word 2010 document that merges data from our back office database. I have a number of calculations in the document that are working fine but one of them has me really stumped.

    In one table cell (D1), the data merges in as a string, either Yes or No. I want to perform a calculation in another cell based upon the value of the string in the other cell. What I tried was:
    {=if(D1="Yes",1*100,0)}

    The intention is that if it's Yes then the cell has the value of 100 otherwise it's 0. But, the formula I tried gives a syntax error.
    Can anyone help with a solution? Many thanks in advance!

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,948
    Thanks
    0
    Thanked 204 Times in 185 Posts
    Word fields cannot reference strings in cells - only numbers. Since this is apparently a mailmerge, though, you should be able to ignore the cell reference entirely and text just the mergefield's content:
    {IF«MyField»= "Yes" 100 0}
    where MyField is your mergefield's name.

    Note: The field brace pairs (i.e. '{ }') for the above example are 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. 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 mailmerge toolbar. The spaces represented in the field construction are all required.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •