Count the number of skips between hits

PokerJoe

Board Regular
Joined
Aug 27, 2005
Messages
63
Cash5v1.1.xls
ABCDEFGHIJK
1C1C2C3C4C5SBH1SBH2SBH3SBH4SBH5
2H19h10sQhJd5h
3H22d7s7dAc4s
4H34dKdKsJc2h
5H45c5h2d8s8c
6H510dJdQdKs4c
7H67hQsQhAs10c
8H710s2d5dAhAc
9H83c6h6cAd5c
10H92h9h10sKsJc
11H10Jd5h2d8s10c
12H117s7hQd2d10d
13H128s2d2h9h10s
14H13KsKd6cQh4s
15H14As10s7s3c6h
16H152hAhJdQdAc
Sheet2




Code:
Private Sub Count_Skips_Between_Hits()
LastRow = Cells(65536, 1).End(xlUp).Row
    For I = 2 To LastRow
            Cells(I, 7).FormulaR1C1 = 'Count the number of skips since the last time this value occurred in any column"
            Cells(I, 8).FormulaR1C1 = "='Count the number of skips since the last time this value occurred in any column"
            Cells(I, 9).FormulaR1C1 = 'Count the number of skips since the last time this value occurred in any column"
            Cells(I, 10).FormulaR1C1 = 'Count the number of skips since the last time this value occurred in any column"
            Cells(I, 11).FormulaR1C1 = "='Count the number of skips since the last time this value occurred in any column"
    Next I
Columns("G:K").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
End Sub

Is there a way to count the number of skips between two ocurrences?

In other words I need to know how many hands were played between the time any card was drawn?

Using the example, "I7" should = 4 and "J12" should = 0.

Any takers to point me in the right direction?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
This won't put formulas in the target cells, but it will fill in the values you are seeking. See if this works for you.
Code:
Private Sub Count_Skips_Between_Hits()
    Dim myRange As Range
    Dim c As Range
    Set myRange = Range("B2", Range("F65536").End(xlUp))
    
    For Each c In myRange
        For i = c.Row - 2 To 1 Step -1
            If Not IsError(Application.Match(c, myRange.Rows(i), 0)) Then
                c.Offset(, 5) = c.Row - 2 - i
                Exit For
            Else
                c.Offset(, 5) = 0
            End If
        Next i
    Next c
End Sub
 
Upvote 0
Amazing...THANK YOU

You guys just continue to amaze me. I'll never be the level of genius many of you are. I'm grateful for your generosity.

:pray: :pray: :pray: THANK YOU AHNOLD!!!

It was exactly what I needed. YOU DA MAN!!!!
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,983
Members
449,092
Latest member
Mr Hughes

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