# index when values repeat then change

#### jimblimm

##### Board Regular
My setup:

A1:A20

S
S
T
S
S
S
S
U
T
S
S
U
S
S
S
S
t
T
R

I am looking for a formula that will tell me how many times the value "s" streaked
4 times then the value "t" followed. Example

S
S
S
S
T

Displayed in c1

And i also need a index of when it occurred in d1

### Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi,
try the code:
Code:
``````Sub SSSST()
Dim tbl(), s As String, i&

tbl = Application.Transpose(Range("a1:a20"))
s = Join(tbl, "")

For i = 1 To Len(s) - 4
If Mid(s, i, 5) = "SSSST" Then
x = x + 1
ReDim Preserve tbl(1 To x)
tbl(x) = i + 4
End If
Next i
Cells(1, 3).Value = UBound(tbl)
Cells(1, 4).Resize(UBound(tbl)) = Application.Transpose(tbl)
End Sub``````
Best regards.

Is there a regular formula i can use mmult maybe

Replies
4
Views
308
Replies
12
Views
270
Replies
2
Views
184
Replies
0
Views
261
Replies
7
Views
331

1,207,255
Messages
6,077,307
Members
446,278
Latest member
hoangquan2310

### 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.

### Which adblocker are you using?

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

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