+ Reply to Thread
Results 1 to 10 of 10

Help With Word Based Excel Formula Using IF/OR Statement

  1. #1
    Registered User
    Join Date
    09-19-2014
    Location
    San Antonio, TX
    MS-Off Ver
    2013
    Posts
    6

    Help With Word Based Excel Formula Using IF/OR Statement

    Hello everyone, so this is what I have so far but this formula does not work for what I am trying to accomplish, can someone help?

    =IF(OR(QQ:="Alton","Alamo",["Pharr")”McAllen”)

    Basically what I need Excel to do is to render the word "McAllen" in column "V" based off of weather or not there is a match in column "Q" of "Alton", "Alamo" or "Pharr". If column "Q" does not match "Alton", "Alamo" or "Pharr" then I need column "V" to remain blank.

    Please Help.

    Also, I am using Excel 2013

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    Place this in V1 and copy it down as far as you need

    =IF(OR(Q1="Alton",Q1="Alamo",Q1="Pharr"),McAllen”,"")

    an OR function requires complete statements in each part, so
    =OR(logical_test1,logical_test2,logical_test3)
    So you need complete tests in each section, not just possible answers you want to compare against
    =OR(A1=Criteria1,A1=Criteria2,A1=Criteria3) will work, but
    =OR(A1=Criteria,Criteria2,Criteria3) will not work, because the logical_tests no longer return a logical TRUE or FALSE value

    The Excel formula tooltip puts the [ ]'s around optional fields to identify that they are optional, placing the [ ]'s in the formula will cause errors though.
    Last edited by Speshul; 09-19-2014 at 12:29 PM.
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  3. #3
    Registered User
    Join Date
    09-19-2014
    Location
    San Antonio, TX
    MS-Off Ver
    2013
    Posts
    6

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    Thank you Speshul for your quick reply! This formula worked perfectly with a couple of tweaks. Here is the final formula I needed to make this work just in case it benefits anyone else:

    =IF(OR(Q:Q="Alton",Q:Q="Alamo",Q:Q="Pharr"),"McAllen","")

    Can anyone tell me why Excel shows the 2nd and 3rd parenthesis in red when writing this formula? Is this because there is a flaw in the equation?

    Thanks Again!

  4. #4
    Registered User
    Join Date
    09-19-2014
    Location
    San Antonio, TX
    MS-Off Ver
    2013
    Posts
    6

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    Also, I hit another snag. I'm wondering is there a way to use multiple if statements in one cell? So please let me try and explain what I am trying to accomplish and then I will show you my current formula.

    Like before I am trying to accomplish something very similar but a bit more complex.

    Basically what I need Excel to do is to render the word "McAllen" in column "V" based off of weather or not there is a match in column "Q" of "Alton", "Alamo" or "Pharr". If column "Q" does not match "Alton", "Alamo" or "Pharr" then I need column "V" to remain blank.
    -or-
    If the words "Alpine" or "Alamogordo" are in the "Q" column then the "V" column needs to render "El Paso"; if neither "Alpine" or "Alamogordo" are in column "Q" then again column "V" would need to remain blank.

    Here is my current formula:

    =IF(OR(Q:Q="Alton",Q:Q="Alamo",Q:Q="Pharr"),"McAllen","") =IF(OR(Q:Q="Alamogordo",Q:Q="Alpine"),"El Paso","")

    I don't even know if this is possible but if it is it would save me a huge deal of time.

    Thanks again!
    Last edited by mhickman; 09-19-2014 at 01:06 PM.

  5. #5
    Registered User
    Join Date
    09-19-2014
    Location
    San Antonio, TX
    MS-Off Ver
    2013
    Posts
    6

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    Also, I hit another snag. I'm wondering is there a way to use multiple if statements in one cell? So please let me try and explain what I am trying to accomplish and then I will show you my current formula.

    Like before I am trying to accomplish something very similar but a bit more complex.

    Basically what I need Excel to do is to render the word "McAllen" in column "V" based off of weather or not there is a match in column "Q" of "Alton", "Alamo" or "Pharr". If column "Q" does not match "Alton", "Alamo" or "Pharr" then I need column "V" to remain blank.
    -or-
    If the words "Alpine" or "Alamogordo" are in the "Q" column then the "V" column needs to render "El Paso"; if neither "Alpine" or "Alamogordo" are in column "Q" then again column "V" would need to remain blank.

    Here is my current formula:

    =IF(OR(Q:Q="Alton",Q:Q="Alamo",Q:Q="Pharr"),"McAllen","") =IF(OR(Q:Q="Alamogordo",Q:Q="Alpine"),"El Paso","")

    I don't even know if this is possible but if it is it would save me a huge deal of time.

    Thanks again!
    Last edited by mhickman; 09-19-2014 at 01:08 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    Yes. You can actually put 64 IF's in one cell.

    Modify your formula to
    =IF(OR(Q:Q="Alton",Q:Q="Alamo",Q:Q="Pharr"),"McAllen",IF(OR(Q:Q="Alamogordo",Q:Q="Alpine"),"El Paso",""))

    Explanation of IF's:


    =IF(logical_test,value_if_true,value_if_false)

    logical_test: This is where you put the test. The rest can be any statement that results in a True or False result, for example A1>15. If A1 is in fact larger than 15, the result will be True. Common operators would be
    .
    • ">" Greater Than
    • "<" Less Than
    • "<>" NOT equal to
    • ">=" Greater than or equal to
    • "<=" Less than or equal to
    • "=" Equal to


    value_if_true: This is the result if logical_test returns a TRUE value.
    value_if_false: As you probably guessed, this is the result if logical test returns a FALSE value.


    A full example of the formula would be:

    =IF(A1=10,A1+10,B1)

    Now, if cell A1 is equal to 10, the result of the formula will be 20. Why? Because if A1=10, the value_if_true will occur, resulting in 10+10
    If A1 is NOT equal to 10, the result of the formula will be whatever the value of B1's cell is

    Remember, any one of the three inputs for the IF function can be another formula, for example, here are two IF's nested:
    =IF(A1=10,A1+10,IF(A1>10,A1,B1-10))
    The value_if_false is another IF function, that will only be executed by Excel if the previous IF statement (A1=10) is False

  7. #7
    Registered User
    Join Date
    09-19-2014
    Location
    San Antonio, TX
    MS-Off Ver
    2013
    Posts
    6

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    Awesome Speshul, this worked flawlessly. Thank you for the explanation as well.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    Quote Originally Posted by Speshul View Post
    Modify your formula to

    =IF(OR(Q:Q="Alton",Q:Q="Alamo",Q:Q="Pharr"),"McAllen",IF(OR(Q:Q="Alamogordo",Q:Q="Alpine"),"El Paso",""))
    Are you sure that's what you want to do?

    Since you're referencing the entire column the formula would have to be array entered.

    Here's another way to write it when there are multiple criteria in an OR function:

    =IF(OR(Q:Q={"Alton","Alamo","Pharr"}),"McAllen",IF(OR(Q:Q={"Alamogordo","Alpine"}),"El Paso",""))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Registered User
    Join Date
    09-19-2014
    Location
    San Antonio, TX
    MS-Off Ver
    2013
    Posts
    6

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    Thanks Tony! That is even better and far simpler since I will need to do this for approximately 25 "Nearest Cities" and about 750 "Cities". I'm trying to organize a database of roughly 750 cities into their respective, "Nearest City". Thanks a ton this is great!

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Help With Word Based Excel Formula Using IF/OR Statement

    You're welcome. Thanks for the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trying to write an if statement in Word/Excel for Mail Merge
    By Rainwater123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2014, 01:45 PM
  2. Convert Word to Excel based upon Word Table of Contents
    By jcappuccino7 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2013, 01:25 PM
  3. Need help with Excel-to-Word find and replace macro based on word filename
    By EnterTheSerpent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2013, 12:48 PM
  4. Where can I find a Billing Statement Template for Word or Excel?
    By Iltid in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-31-2005, 10:05 AM
  5. [SOLVED] How can I create an IF statement in Excel that uses the word "con.
    By BobbiCisse in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-22-2005, 03:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1