Match a small string against a large string

newbie1973

New Member
Joined
Apr 1, 2012
Messages
12
I am looking to match a single string of 7 numbers against a batch of larger strings of 25 numbers. Both the 7 and 25 strings are random but in sequence, 6..12..25 etc. I want to find the first time that a 7 string occurs in a 25 string, even if there are intervening numbers in the 25 sequence. I.E. 2 4 6 8 10 12 14 found in a 25 string that had 1 2 3 4 6 8 10 11 12 13 14 would be a match.

On another forum I received an excellent formula to do it when the strings are each in one cell separated by commas.

Is there an "easy" way to do this if the numbers in the 7 and 25 strings are in individual cells?

Thanks for any suggestions.
 
I have not used UDF's before, so I'm looking forward to trying it. The cell address reference is perfect. Unfortunately, I just installed recently my Excel2010 on a new computer, and I can't get the ALT/F11 to work, it was working on the old machine. Google shows a number of hits on the issue, so I guess that's my next project, either that or use the old machine.

Regardless, I love the idea of using a UDF on this and will report back.

I do see where cross-posting gets confusing. To update, I have a solution for single celled strings with spaces and commas. I can move forward with either and appreciate the input. I would still like to test a solution with the strings in multiple cells if someone has one.

Thanks again for the UDF idea.
I don't have XL2010 myself, but perhaps you can find the equivalent to the following from XL2007 and implement it on your system. In Excel Options for XL2007, there is an item labeled "Popular" which has its own dialog page and on that dialog page is a check box labeled "Show Developer tab in the Ribbon". Putting a check mark in that check box and clicking OK adds the indicated new tab... on that tab is a button labeled "Visual Basic" which takes you directly into the VB editor. Can you find the equivalent on your system and, if so, does it take you into the VB editor?

Oh, one thing I forgot to mention about the UDF that I posted... the SearchMe range is not restricted to a single column nor a single row for that matter, the range can be any rectangle range of cells (providing the cell the formula is in is not part of that range, of course).
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I was able to add the "Developer Tab" via options, via a "Customize Ribbon" tab. Once I open the Developer Tab however, about 1/2 the options are greyed out, including the Virtual Basic and Macro buttons. From some search suggestions, I made changes to my Trust Center settings, but that made no change to the Developer Tab. I do now have a nice yellow triangle warning me about my Macro Security.
 
Upvote 0
I was able to add the "Developer Tab" via options, via a "Customize Ribbon" tab. Once I open the Developer Tab however, about 1/2 the options are greyed out, including the Virtual Basic and Macro buttons. From some search suggestions, I made changes to my Trust Center settings, but that made no change to the Developer Tab. I do now have a nice yellow triangle warning me about my Macro Security.
Hmm, does anything at this link help?

http://support.microsoft.com/kb/282847
 
Upvote 0
Sure looks and sounds like my issue. I may have to re-install the program. I don't remember proactively selecting "not available" for the VBA when I installed it the first time.
 
Upvote 0
I could not get the macro/vba section of my Developer tab to work, and have officially given up. I did take mikerickson's comma solution and modified it for spaces, since it looks "cleaner" on the worksheet, and it's working great. Assuming that any "multiple cell" solutions would require a macro, I am calling this one solved. Thanks for the all the helpful input.

Edit: I guess you don't mark them as such on the forum, but "solved" it is.
 
Last edited:
Upvote 0
Assuming that A2:Y5 contains each set of 25 numbers, AA2:AG2 contains the 7 numbers, and that no numbers repeat, try the following formula that needs to be confirmed with CONTROL+SHIFT+ENTER...

=MATCH(TRUE,MMULT(ISNUMBER(MATCH($A$2:$Y$5,$AA2:$AG2,0))+0,TRANSPOSE(COLUMN($A$2:$Y$5)^0))=7,0)
 
Upvote 0
Wow. A preliminary testing shows it working perfectly. I will play with it some more tomorrow, but it looks great. I'm amazed what you guys can come up with. Thanks.
 
Upvote 0
Wow. A preliminary testing shows it working perfectly. I will play with it some more tomorrow, but it looks great. I'm amazed what you guys can come up with. Thanks.

You're very welcome!
 
Upvote 0

Forum statistics

Threads
1,215,872
Messages
6,127,430
Members
449,382
Latest member
DonnaRisso

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