趣味のエクセルで当てよう!ロト・ナンバーズ

当選狙いで、ナンバーズ4をメインにロト、ビンゴ5などの各種データリストや、それらの分析用エクセルVBAなどについて書いてます。

マクロ作成方法 9(N4復活数字集計)





ナンバーズにおいて復活数字と言う考え方があります。


たとえば


 4884回 9923 当選


 4885回 4445 当選


 4886回 6562 当選   の時に


   4884回の 9923の2、3、9が4885回に出ないで 4886回に2が出ている時


   2が復活数字です(1回休んで出る事)。3,9は復活数字ではないですね。


 
 これを集計するわけですが、どういう考えが必要かですね?


たとえば2回分でカウントを取って判定する。


6562の2の場合、4445と9923で2があるかどうかの判定は出来ると思います。



変数 知らなかった本当の使い方! 


Sub n4bx_fukkatu_ta()
 Dim xa(7) As long,  ii As long, i As long
 
 Sheets("出現数").Select


  Range("jj5:js5").Select
    Selection.ClearContents
  
    Call saikeisanoff  '再計算等停止
 
    i = 6



Do Until Sheets("ストレートパターン").Cells(i, 3) = ""


    


  For ii = 4 To 7  '番号の4列から7列のデータ処理
  
               xa(ii) = Sheets("ストレートパターン").Cells(i, ii)
   
        If WorksheetFunction.CountIf(Range(Sheets("ストレートパターン").Cells(i - 2, 4), Sheets("ストレートパターン").Cells(i - 2, 7)), _
         xa(ii)) >= 1 Then '前々回に同じ数字があれば
         
        If WorksheetFunction.CountIf(Range(Sheets("ストレートパターン").Cells(i - 1, 4), Sheets("ストレートパターン").Cells(i - 1, 7)), _
         xa(ii)) = 0 Then '前回に同じ数字が無かったら
           
       Cells(5, 270 + xa(ii)) = Cells(5, 270 + xa(ii)) + 1 ’今回の復活集計
    
       End If
   
       End If
      
  Next ii
 
  i = i + 1


 Loop
 
     Range("JJ5:JS5").Select '条件での色付 マクロ自動記録作成
    Selection.FormatConditions.AddAboveAverage
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).AboveBelow = xlAboveAverage
    With Selection.FormatConditions(1).Font
        .Color = -16752384
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13561798
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Selection.FormatConditions.AddAboveAverage
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).AboveBelow = xlBelowAverage
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
 
 
 
     Call saikeisanon  '再計算開始
 
  Cells(1, 270).Select
   Cells(1, 279) = i - 4 & " 回"



End Sub