help with IF statement syntax

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having some (basic) problems with using IF statement and fields in Word 2000. Seems my Excel experience is making it worse! I have table1 (bookmarked) that contains a simple percent calculation field in cell c1: {=(a1/b1)*100\#"0.00%"}. This works fine.

In cell d1, I now want to take the result of that calculation from c1 (the percentage) and compare it with a percentage in table2 (bookmarked) cell a1. If it's less insert text "less than text here" if its greater insert text "greater than text here".

Can someone please tell me how the field code in d1 should read to achieve this.
Thanks
MB.
 
Hi Mike,

The Excel syntax works OK for purely numeric stuff, but you need a different
syntax for string processing. Alternatively, you could stick with the Excel
syntax and use Word's numeric picture switches to control the output.

For some ideas on how to go implement either approach, take a look at the
Word document at:
http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=wrd&Number=365442
(url all one line)


Cheers

Mike B said:
I'm having some (basic) problems with using IF statement and fields in
Word 2000. Seems my Excel experience is making it worse! I have table1
(bookmarked) that contains a simple percent calculation field in cell c1:
{=(a1/b1)*100\#"0.00%"}. This works fine.
In cell d1, I now want to take the result of that calculation from c1 (the
percentage) and compare it with a percentage in table2 (bookmarked) cell a1.
If it's less insert text "less than text here" if its greater insert text
"greater than text here".
 
Ive read the document, thanks very much but I'm still very confused unfortunately.
From what it says, It's not possible to use an IF statement in a table to compare two pieces of numerical data and then return a (true or false) text string?

say A1=100 and A2=20

ie in Excel this would read: IF(A1>A2,"hello","goodbye") - Excel outputs hello

in Word I'm using:

{=IF(bookmarkA1>bookmarkA2,bookmarkhello,bookmarkgoodbye)}

this outputs 0?
 
Mike,

I am a little confused by your syntax. If you want the result to return the
literal text "Hello" or "Goodbye," then use an IF field:


{ IF {=a1} > {=a2}"Hello""Goodbye"}



Where {=a1} and {=a2} represents the value in cells a1 and a2 of the table.



If you want the result to return text bookmarked with bookmarks named
"Hello" and "Goodbye," use:



{ IF {=a1} > {=a2}{Hello}{Goodbye}}

If you want the result of the comparison to be a numerical value you can use
IF in a formula field:

{=IF (a1 > a2,10,20)}
 
If you bookmark the items you want to calculate, the correct syntax for
bookmarks called A1 and A2 would be

{IF {REF A1} > {REF A2} "Hello" "Goodbye"}
or even
{IF {A1} > {A2} "Hello" "Goodbye"}

The curly brackets are field boundaries (CTRL+F9).

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top