# Set of data with certain patterns - find next value after pattern occurs

#### BBXAXX

##### New Member
Hello, I have set of data in column like this for example:

1
0
1
0
0
1
1

1
0
1
1

Now, as you can see BOLD numbers is pattern for example pattern for last 3 numbers in given data set it: 0,1,1. I want to find next value in set of data IF my patterns occurs in this set of data. So in example above I want Excel to give me result: 1,because number "1" is the number that occurs after given pattern 0,1,1. I want Excel to count all "1" and "0" that occurs after given pattern.

I know that I can make another column that helps me in doing that, but I have so much data that my RAM memory can't keep up with all the "helper" columns so I need to find other solution I dont know maybe OFFSET or LOOKUP formula can help me to do this task?

I would love to hear any help from someone who can direct me into right path to solve that problem

Thank you very much in advance
BBXAXX

#### Rick Rothstein

##### MrExcel MVP
Hello, I have set of data in column like this for example:

1
0
1
0
0
1
1

1
0
1
1

Now, as you can see BOLD numbers is pattern for example pattern for last 3 numbers in given data set it: 0,1,1. I want to find next value in set of data IF my patterns occurs in this set of data. So in example above I want Excel to give me result: 1,because number "1" is the number that occurs after given pattern 0,1,1. I want Excel to count all "1" and "0" that occurs after given pattern.
Can you show us the result you want and tell us in what cell or cells you want it? I ask because the highlighted section is confusing to me... you say you want Excel to give you "1" as the answer, but then you go on to say you want a count of all "1" and "0" after the pattern (what follows the "1" you said originally you wanted as answer is, in fact, your pattern).

Last edited:

#### BBXAXX

##### New Member
I will explain this problem in screen below:

Column A1:A22 have some binary numbers (0, 1). As you can see I highlighted numbers with GREEN fill color that match my pattern I want to find.
Column C5:C22 have formula as you can see in formula box, that CONCATENATE first four numbers in data set and check if this first four numbers matches my pattern.
If this first four numbers match my pattern, I want Excel to write NEXT number that is right after this pattern.

The biggest problem is that I can't do this this way because I have data set that have approximately 30.000 binary records in it, and my RAM memory can't handle that much of CONCANTENATE formula to count all NEXT values, after my pattern occurs.
I want someone to help me find other way without making HELPER columns, I want Excel formula, that in steps:

1. Search for pattern in data set..
2. IF pattern in data set matches my desired pattern, make AVERAGE of all values right after pattern occurs. So in example above my AVERAGE in cells C5:C22 = 0,66

I hope that I explain this in details so you know my problem, I need formula to do all the math stuff, I can't use helper columns like in example above.

1,081,705
Messages
5,360,751
Members
400,595
Latest member
T_Dubs

### This Week's Hot Topics

• VBA (Userform)
Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
• List box that changes fill color
Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
• Remove duplicates and retain one. Cross-linked cases
Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
• VBA Copy and Paste With Duplicates
Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
• Macro
is it possible for a macro to run if the active cell value is different to the value above it
• IF DATE and TIME
I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...