# counting a streak of values

#### jimblimm

##### Board Regular
i have this formula
=COUNTIFS(B1:B10,"s",B2:B11,"s",B3:B12,"s",B4:B13,"s",B5:B14,"s")

i am wanting to count if the s streaks 4 times....
example

s
s
s
s

is there a shorter formula i can use to do the exact same thing but i can have a variable number of times it should streak in a different cell
example
b1=number of time the "s" repeat/streaks

### Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try this:
Code:
``````Sub Count()
Dim tbl(), s As String, i&

tbl = Application.Transpose(Range("b1:b20"))
s = Join(tbl, "")

For i = 1 To Len(s) - 4
If Mid(s, i, 4) = "SSSS" Then
x = x + 1
ReDim Preserve tbl(1 To x)
tbl(x) = i + 4
End If
Next i
Cells(1, 3).Value = UBound(tbl)
End Sub``````

Replies
2
Views
879
Replies
12
Views
513
Replies
3
Views
465
Replies
4
Views
1K
Replies
2
Views
234

1,212,099
Messages
6,105,957
Members
447,986
Latest member
dicklim39

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