|
▼fool さん:
こんな感じでは
Sub TEST_Pattrn()
Dim varD As Variant
Dim varR As Variant
Dim strF As String
Dim i As Long
Dim j As Long
Dim strMsg As String
strF = "101" ' 検索値
varD = Range("B1").Resize(Range("B" & Rows.Count).End(xlUp).Row).Value
varD = Application.Transpose(varD)
varD = Join(varD, "")
' パターン1
'1001101101011' の時
' xxxyyy
varR = Split(varD, strF) '2個
strMsg = "パターン1は " & UBound(varR) & "個 " & vbCrLf
' パターン2
'1001101101011' の時
' xxxyyy
' zzz
j = 1
i = 0
Do
j = InStr(j, varD, strF)
If j = 0 Then Exit Do
i = i + 1
j = j + 1
Loop
strMsg = strMsg & "パターン2は " & i & "個"
MsgBox strMsg
End Sub
|
|