+ Reply to Thread
Results 1 to 17 of 17

search within an array/table

  1. #1
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    search within an array/table

    Hi,

    I have a small animal database which has the animal name and the number of legs it has.

    I want to create a searchable database, whereby I type the animal name (in any format eg proper, lower etc) in column A, it returns the number of legs in column B.

    I know I can do this job using index and match, however how do tell the formula to ignore something when someone puts a word or leaves the cell blank.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    03-18-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    251

    Re: search within an array/table

    Hi,

    Just use

    =INDEX(B:B, MATCH(F4, A:A,0))

    The formula is non-case sensitive, it will take care any form like below

    dOg
    CAT
    SnaKE
    HuMAN

    unless you requirement is more than that then you can use sumproduct with index match for multiple conditions
    Attached Files Attached Files
    Christopher Yap

  3. #3
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    Re: search within an array/table

    Quote Originally Posted by bluesky63 View Post
    Hi,

    Just use

    =INDEX(B:B, MATCH(F4, A:A,0))

    The formula is non-case sensitive, it will take care any form like below

    dOg
    CAT
    SnaKE
    HuMAN

    unless you requirement is more than that then you can use sumproduct with index match for multiple conditions
    I did, but when ever I come across a word not in my database, it prints NA which i don't want.

  4. #4
    Forum Contributor
    Join Date
    03-18-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    251

    Re: search within an array/table

    Hi,

    the use IFERROR(INDEX(B:B, MATCH(F4, A:A,0)), "Not found"), or whatever message that you display

    or you can attach a more comprehensive datasets that will show these error for me to take a look

  5. #5
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    Re: search within an array/table

    Quote Originally Posted by bluesky63 View Post
    Hi,

    the use IFERROR(INDEX(B:B, MATCH(F4, A:A,0)), "Not found"), or whatever message that you display

    or you can attach a more comprehensive datasets that will show these error for me to take a look
    I don't want it to do anything on that cell. So having a string like "not found" or "" is not what i want. I want it to no do anything or skip it.

  6. #6
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,411

    Re: search within an array/table

    Cell B3 formula , drag down

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by wk9128; 02-04-2022 at 05:17 AM.

  7. #7
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    Re: search within an array/table

    Quote Originally Posted by wk9128 View Post
    Cell B3 formula , drag down

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    this worked, can this be done using index match?

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: search within an array/table

    If someone mis-spells cat as cyat... you'll need an entirely different approach (Microsoft fuzzy lookup, free from their www). But if you just want to ensure that "tiny cat" is seens as being "cat" and returns 4, then use:

    =IFERROR(LOOKUP(1000,SEARCH($F$4:$F$7,A3),$G$4:$G$7),"")

    Make a note to explain the exceptions and real requirements right fromt he start.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  9. #9
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    Re: search within an array/table

    Noted!

    Does search take in to account variations of the words?
    Last edited by AliGW; 02-04-2022 at 05:13 AM. Reason: PLEASE don't quote unnecessarily!

  10. #10
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,411

    Re: search within an array/table

    ANS. post #7

    index + match

    Try this formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by wk9128; 02-04-2022 at 05:18 AM.

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: search within an array/table

    wkd9128. Does your formula work for "tiny cat" in column A? It doesn't.

    Bob, what do you mean by "variations of the words"? My formula will work with "tiny cat", or "cat-creature", but will not work with "cyat". You need to define the degree of variability/sloppy data entry that can happen.

  12. #12
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    Re: search within an array/table

    Variation such as any word that has the word cat eg categories.
    Last edited by AliGW; 02-04-2022 at 05:14 AM. Reason: PLEASE don't quote unnecessarily!

  13. #13
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    Re: search within an array/table

    @glenn what is the purpose of the 1000 in your code?
    Please Login or Register  to view this content.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: search within an array/table

    It's just a big number that needs to be larger than the position of the first character of the keyword (cat) in the search string (tiny cat). In this case cat begins at position 6 of the string "tiny cat". As long as the number is > than the largest value, it works. So... 1000 is simply a big number, larger than your largest string. 1000, 10^6, 10^9... it does not matter at all. Just needs to be big.

  15. #15
    Forum Contributor
    Join Date
    12-03-2020
    Location
    australia
    MS-Off Ver
    365
    Posts
    108

    Re: search within an array/table

    Quote Originally Posted by Glenn Kennedy View Post
    It's just a big number that needs to be larger than the position of the first character of the keyword (cat) in the search string (tiny cat). In this case cat begins at position 6 of the string "tiny cat". As long as the number is > than the largest value, it works. So... 1000 is simply a big number, larger than your largest string. 1000, 10^6, 10^9... it does not matter at all. Just needs to be big.
    I understand, thank you for the clear explanation.

  16. #16
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,411

    Re: search within an array/table

    Quote Originally Posted by Glenn Kennedy View Post
    wkd9128. Does your formula work for "tiny cat" in column A? It doesn't.

    Bob, what do you mean by "variations of the words"? My formula will work with "tiny cat", or "cat-creature", but will not work with "cyat". You need to define the degree of variability/sloppy data entry that can happen.
    @Glenn Kennedy Thank you POST #6 AND POST #9 The formula has been modified

  17. #17
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,411

    Re: search within an array/table

    @bob112233 You're Welcome. Glad to help . Thank You for the feedback

    If you finally get a solution please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".
    - Please click on the *Add Reputation button at the bottom left. Whoever helps you, give it to whoever you like

+ 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. Table Array Search
    By Hoppy1958 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-20-2019, 09:56 AM
  2. [SOLVED] vlookup: search for value in SECOND column of table array and return value from FIRST
    By matt_pl in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-28-2014, 06:02 AM
  3. [SOLVED] Search for single value in table array
    By andrewv19 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-19-2013, 06:44 PM
  4. macro to put zero's in table array - table array will vary in size each time
    By leanne2011 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2012, 06:12 AM
  5. Replies: 2
    Last Post: 01-30-2012, 12:18 AM
  6. Table Array Search [2]
    By ExcelJunkie in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-11-2006, 09:56 PM
  7. Table Array Search
    By ExcelJunkie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-11-2006, 05:01 PM

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