|
▼Toshi さん:
書き終えてアップしようとしたら、既に同じようなものがぴかるさんから
出ていましたが、書いちゃったのでアップします。
Option Explicit
Sub Sample()
Dim c As Range
Dim oldX As Boolean
Dim oldStr As String
Dim maxCnt As Long, curCnt As Long
With Worksheets("Sheet1") '<== 実際のシート名に
For Each c In .Range("A1:A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1)
If oldStr <> c.Value Then
If oldX Then
If curCnt > maxCnt Then maxCnt = curCnt
End If
curCnt = 0
End If
curCnt = curCnt + 1
oldStr = c.Value
oldX = False
If oldStr = "X" Then oldX = True
Next
End With
MsgBox "記録は" & maxCnt & "連敗です"
End Sub
|
|