I'm wondering if it's possible to use some VBA to find defined patterns in a whole bunch of 5char strings? I've explored the "instr" function but I'm not sure if it will perform the task I require which is basically to find patterns in the string like the following;
ABABA
BCBCB
.....
EFEFE
Or any such pattern where the 1st char is the same as chars 3 & 5, and the 2nd char is the same as char 4.
Any help or direction would be gratefully received.
Kind regards
Jim
My turn:
This assumes that you have multiple words in each string. It returns an array of true false.
Edit
To find it there are any patterns use this UDF:
It will return 12121 on "ABABA"
You can paste this in a module in the workbook then use it like a formula:
=findPattern("A1")
Copy it down. Then sort on the column, it will place all like patterns together with the most patternized (11111) to the least (12345).Then you could also filter on this column for any pattern you desire.
Try the
Like
operator:Or use the
Mid()
function:OR to check for both conditions:
You can do it without VBA and it would still be fast enough:
just replace "ABABA" with corresponding cell address and that's it
Okay so I actually went for this in the end...
Embarrassingly simple, literally cannot believe I didn't consider this as an option first and instead just assumed it should be done in VBA. A valuable lesson!
Had to mod the formulae anyway because my initial pattern flag (1,3,5 & 2,4) evaluated to big fat FALSE across the board, so I decided to look for 1,3 & 2,4 with 5 being anything. As I mentioned in my comment to @zedfoxus this gets me to where I need to be right now but it would be great to use VBA to productionise this. I'm going to review all your answers so thanks for taking the time to respond, I frickin' love this place!
PEACE!
Throwing my hat in the ring XD