index when values repeat then change

jimblimm

Board Regular
Joined
May 11, 2012
Messages
219
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

The answer should be 1

Displayed in c1

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

Answer should be 17.
 

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.
 
Upvote 0

Forum statistics

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