+ Reply to Thread
Results 1 to 3 of 3

How Do I Use the Find Function in an Array Formula

  1. #1
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    How Do I Use the Find Function in an Array Formula

    Hi! I know how to use the find function in Excel and I also know how to loop through an array in VBA to see if a certain string is present. However, I'd like to learn how to use an array formula within a worksheet to see if a cell's string value is in a value of an array that may contain those unique strings but are also surrounded by other strings. For instance:

    Range A1:A10 is my first array and can be visualized as ("Electricity", "Water", "Sewage", etc...)
    Range B1:B10, which are in an arbitrary order that does not correlate with the corresponding cell in column A, may look like ("The bill for Water was...","Last month, my electricity bill was...", etc...).

    How would I do something along the lines of {=find(A1,B1:B10,1)}? I am trying to see if each individual element of the first array, range A1:A10, appears in the second array, range B1:B10.

    As mentioned, this is easy to do in VBA, however, I am just curious as to how this would be done.

    Thanks!

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,447

    Re: How Do I Use the Find Function in an Array Formula

    I would tend not to use the FIND() function for this. I would probably use one of Excel's lookup functions with the exact match option. When you choose the exact match option for one of Excel's lookup functions, you can use wildcard characters (like * or ?) to search for a string within the other strings. For the scenario you describe, something like =MATCH(CONCATENATE("*",A1,"*"),$B$1:$B$10,0) will return the row number that contains the text string if it exists. If not, it will return the N/A error.

    (If you object to the N/A error value when it is not found, you can nest that inside of an IFERROR() or IFNA() function (or similar) to trap the error and return whatever you would prefer to return.)

    Would something like that work for you?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: How Do I Use the Find Function in an Array Formula

    Quote Originally Posted by MrShorty View Post
    I would tend not to use the FIND() function for this. I would probably use one of Excel's lookup functions with the exact match option. When you choose the exact match option for one of Excel's lookup functions, you can use wildcard characters (like * or ?) to search for a string within the other strings. For the scenario you describe, something like =MATCH(CONCATENATE("*",A1,"*"),$B$1:$B$10,0) will return the row number that contains the text string if it exists. If not, it will return the N/A error.

    (If you object to the N/A error value when it is not found, you can nest that inside of an IFERROR() or IFNA() function (or similar) to trap the error and return whatever you would prefer to return.)

    Would something like that work for you?
    That works amazingly :D Thanks!

+ 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. Find the most middle value in array VBA or Excel function
    By robert12345 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-25-2017, 10:00 AM
  2. Find max in array, return corresponding value in array, without max function
    By cshwkhelp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2017, 11:26 PM
  3. Replies: 3
    Last Post: 04-02-2016, 08:16 PM
  4. How to use FIND() or a similar function with an array
    By apiekar42 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-19-2013, 02:25 PM
  5. [SOLVED] using array in find function
    By hluk in forum Excel General
    Replies: 3
    Last Post: 05-05-2012, 02:54 AM
  6. Find function - use with an array
    By jamsta1972 in forum Excel General
    Replies: 6
    Last Post: 04-10-2011, 05:28 PM
  7. [SOLVED] Using Array variable in FIND function
    By GreenInIowa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2005, 04:09 PM

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