Why do Index and Match do not work when you've multiple numbers in Cell

nsa1

New Member
Joined
Jul 11, 2023
Messages
39
Office Version
  1. 2010
Hello,

I am trying to figure out if Index and Match function can work for indexing numbers separated by "," to be assign..

See the snapshot below

Thanks,
NA
 

Attachments

  • IndexMatch.png
    IndexMatch.png
    25 KB · Views: 21

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Can you paste your actual formula.
 
Upvote 0
Thanks for that.
How about
Excel Formula:
=IF(ISNA(MATCH("*"&E1&"*",B2:B4,0)),"",INDEX(A2:B4,MATCH("*"&E1&"*",B2:B4,0),1))
 
Upvote 0
Thanks for that.
How about
Excel Formula:
=IF(ISNA(MATCH("*"&E1&"*",B2:B4,0)),"",INDEX(A2:B4,MATCH("*"&E1&"*",B2:B4,0),1))
It gives me 4 as answer... and changes input field from X to B?
 

Attachments

  • IndexMatch3.png
    IndexMatch3.png
    39.3 KB · Views: 10
Upvote 0
Oops Sorry.. I tried it but it gives me 1,2,3. I want X = 1, Y =2 and Z=3...is that possible?
 
Upvote 0
I understand but I am not looking foe "1,2,3".

I have a situation in my spreadsheet where if I come across a cell with "X Y Z" and it's Index match is "1,2,3" then I want to have X = 1, Y =2 and Z = 3....not printing "1,2,3" for all X, Y and Z?
 
Upvote 0
Try the following UDF:


VBA Code:
Function IndexWithComma(rng As Range, cell As String)
  Dim c As Range
  Dim v As Variant, n As Variant
  Dim i As Long
 
  For Each c In rng.Columns(2).Cells
    v = Split(Replace(c.Cells(1).Value, Chr(10), ","), ",")
    n = Split(c.Offset(, -1).Cells(1).Value, ",")
    If UBound(v) = UBound(n) Then
      For i = 0 To UBound(v)
        If LCase(v(i)) = LCase(cell) Then
          IndexWithComma = n(i)
          Exit Function
        End If
      Next
    End If
  Next
  IndexWithComma = ""
End Function


HOW TO INSTALL UDFs (User Defined Functions)
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use IndexWithComma just like it was a built-in Excel function.​
For example:

Dante Amor
ABCDEFGHIJ
1NumberVariableVariableAYmhellobyez
21,2,3X Y ZValue42 673
34A
45B
56,7hello bye
6
7
8
9
10
Hoja3
Cell Formulas
RangeFormula
E2:J2E2=IndexWithComma($A$2:$B$10,E1)


--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top