# Thread: Help with IF statement

1. ## Help with IF statement

I am trying to find if it is possible to write an If statement that would give a value if something is between two numbers. I am trying to get something that says IF Mergfield M_262 is >=11 then 1 OR IF <=12 but >=23 then 2 OR IF <=24 but >=35 then 3 OR IF <=36 but >=47 then 4 OF IF <=48 but >=59 then 5 OF IF <=60 but >=71 then 6

2. http://support.microsoft.com/kb/211363 covers using nested if fields, though I'm trying to think if there would be a neater solution. I do think that REVERSING the order would be simpler

if mergefield >lastvalue,6, if mergefield >secondlastvalue,5 etc

3. As Aidanh notes, reversing the order would be simpler.

This is aircode and will depend on the language used

Select M_262
Case >=71
do 6
Case >=59
do 5
...
Case >=11
do 1
Case else
Do nothing?

Other examples here

4. I would use a CASE statement for that, assuming there is such a thing in Word.

cheers, Paul

5. Snap! Nearly.

cheers, Paul

6. Originally Posted by Paul T
Snap! Nearly.

cheers, Paul
Hehe!

At least we are giving the same advice!

7. Originally Posted by TMarx
I am trying to find if it is possible to write an If statement that would give a value if something is between two numbers. I am trying to get something that says IF Mergfield M_262 is >=11 then 1 OR IF <=12 but >=23 then 2 OR IF <=24 but >=35 then 3 OR IF <=36 but >=47 then 4 OF IF <=48 but >=59 then 5 OF IF <=60 but >=71 then 6
I'm fairly well-versed in field codes but I have no idea what you mean by constructions like "IF Mergfield M_262 is >=11 then 1 OR IF <=12 but >=23 then 2". What are 'OR" and 'but' supposed to mean in this context? After all a value cannot both be '<=12' and '>=23'. Although one can create an OR test, it's not apparent from you post whether you want that, an AND test or an ELSE result.

8. I rather assumed the > and < signs were muddled up in the OP as if they were read as one assumes is intended it makes sense - hence the initial replies! IF this is to be done with Mail Merge, then it may be more sensible to use the data source to do the work for you - excel as a data source for instance would allow the use of Vlookup to simplify the process.

#### Posting Permissions

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