Finding the index of a matching wildcard in excel

前端 未结 3 906
栀梦
栀梦 2021-01-23 09:20

Given a sheet like so:

Sheet 1

Product Name
-----------------
Fancy Shoes
Plain Shoes
Comfy Slippers
Nice Loafers
Pressed Shirt
Tee Shirt
Collared Button-Up


        
相关标签:
3条回答
  • 2021-01-23 09:40

    The below is an array formula (entered with Ctrl+Shift+Enter):

    =INDEX(Sheet2!$B$1:$B$5,MATCH(1,MATCH(Sheet2!$A$1:$A$5,Sheet1!A1,0),0))
    

    You can use "Formulas" > "Evaluate Formula" on the cell containing the formula to see how it's working step by step.

    0 讨论(0)
  • 2021-01-23 09:44

    If there are only two words in each cell and the word that determines the category (ex.: Shoes, Slippers, Shirt, etc...) is always second, you can use the following INDEX/MATCH to get the category:

    =INDEX('Sheet 2'!B$2:B$6,MATCH(MID('Sheet 1'!A2,FIND(" ",'Sheet 1'!A2)+1,LEN('Sheet 1'!A2)-FIND(" ",'Sheet 1'!A2)),'Sheet 2'!A$2:A$6,0))
    
    0 讨论(0)
  • 2021-01-23 09:48

    Based on my reading here (specifically the note at the bottom), this seems to not be possible using VLOOKUP alone. If all of your wildcards don't have spaces, you could do it like this: (not an explicit formula, just a list of algorithmic steps)

    • Reverse the string, with something like this (this is an array formula, so Ctrl+Shift+Enter is required to use it)
    • Use FIND to get the location of the first space in the reversed version, subtracting that from the LEN of the string gives you the amount of string before the wildcard bit.
    • Use RIGHT to truncate the string to the wildcard, and use that with VLOOKUP.
    0 讨论(0)
提交回复
热议问题