Word's "field language" is very limited compared to the functions and operators available in Excel. Depending on what you're doing, the simplest thing may be to embed a suitable Excel sheet (or link to one).
The only type of field code that lets you reference a table cell (usually using A1-style notation) only works with numeric values in the cell. You can't for example, put "abc" in cell A1 of a table and use {=A1}
to make a copy of that in another cell.
The {=}
field essentially only works with numbers, not text or dates, and even the IF(,,)
function in the {=}
field onl allows numbers in all 3 of its parameters.
There are no text functions if the kind you will find in other languages (such as VBA) such as SUBSTRING
, MID
, LEN
and so on. (except there is concatenation, in a sense, and there is something like a VBA LIKE operator).
So for example to do your { =IF(C4="x";"YES";"NO") }
you have to do this:
(some simplifications are possible in this case)
The problem with text comparisons with cell contents is that if you select the cell content and bookmark it, it's easy to delete the bookmark or, after editing the cell content, to end up with a situation where the bookmark does not actually reference the entire content of the cell. But nor can you get away with marking the entire cell either - the { IF } field just won't work.
For a numeric comparison, e.g. compare cell C4 with 1, but where you want a text result, you can either use an { IF } field (as above, not to be confused with the IF(,,) function), or you can use an { = } field where you specify the text results in a "numeric format". e.g.
{ IF {=C4} = 1 "one" "not one" }
or something like
{ =C4=1 \#"'one';;'not one'" }
All the {} have to be the special field code braces that yu can insert using e.g. ctrl-F9 on Windows desktop Word.