+ Reply to Thread
Results 1 to 5 of 5

How do I create an IF function to include an array?

  1. #1
    Registered User
    Join Date
    12-24-2014
    Location
    USA
    MS-Off Ver
    None
    Posts
    9

    Lightbulb How do I create an IF function to include an array?

    For example, column C has a list of city names from around the country.

    Column G includes a list of all the cities that we service.

    I want to create a formula that says, "if the city name in column C is anywhere in the array G2:G200, display the city name in column D (in the respective row), otherwise, display "none."

    Please help and thank you!

  2. #2
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: How do I create an IF function to include an array?

    You don't necessarily have to use an IF statement for this. You could use an INDEX/MATCH combo. Try this:

    Please Login or Register  to view this content.
    Tailor the G column references to match your data set, and make sure the C column reference is on the first cell that contains data.

    Will something like that work?
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: How do I create an IF function to include an array?

    =IFERROR(INDEX(G2:G200,MATCH(C2,G2:G200,0)),"NONE")

    or

    =IFERROR(LOOKUP(2,1/(G2:G200=C2),G2:G200),"NONE")

    or

    =IF(ISNUMBER(SEARCH(C2,G2:G200)),G2:G200,"NONE")

    or

    =IF(COUNTIF(G2:G200,C2),C2,"NONE")
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  4. #4
    Registered User
    Join Date
    12-24-2014
    Location
    USA
    MS-Off Ver
    None
    Posts
    9

    Re: How do I create an IF function to include an array?

    You are brilliant and just saved me days of work. Thank you very much and happy holidays!!

  5. #5
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: How do I create an IF function to include an array?

    Happy holidays

+ 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. Include array reference into loop
    By Deltadart in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-04-2014, 07:01 PM
  2. Replies: 18
    Last Post: 01-02-2014, 02:49 PM
  3. How to create a custom function that uses an array as input.
    By KTWM in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-21-2013, 12:49 AM
  4. [SOLVED] LINESTIF - Can you help me create an array formula to perform this function without VBA?
    By jglassmanba in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-26-2012, 05:45 PM
  5. Change array to include new cells
    By nsorden in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-15-2009, 06:10 AM

Tags for this Thread

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