Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Jan 2015
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #2
    New Lounger
    Join Date
    Jan 2015
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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. #3
    WS Lounge VIP Browni's Avatar
    Join Date
    Dec 2009
    Location
    Rochdale, UK
    Posts
    1,651
    Thanks
    38
    Thanked 161 Times in 139 Posts
    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. #4
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,180
    Thanks
    47
    Thanked 983 Times in 913 Posts
    I would use a CASE statement for that, assuming there is such a thing in Word.

    cheers, Paul

  5. #5
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,180
    Thanks
    47
    Thanked 983 Times in 913 Posts
    Snap! Nearly.

    cheers, Paul

  6. #6
    WS Lounge VIP Browni's Avatar
    Join Date
    Dec 2009
    Location
    Rochdale, UK
    Posts
    1,651
    Thanks
    38
    Thanked 161 Times in 139 Posts
    Quote Originally Posted by Paul T View Post
    Snap! Nearly.

    cheers, Paul
    Hehe!

    At least we are giving the same advice!

  7. #7
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by TMarx View Post
    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.
    Last edited by macropod; 2015-01-30 at 16:50.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. #8
    New Lounger
    Join Date
    Jan 2015
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.
    Last edited by AidanH; 2015-02-03 at 07:03.

Posting Permissions

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