ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

½Ð°Ý¦p¦ó¥ÎARRAY°µ¸ê®Æ¤ñ¹ï¡H

¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-12-16 17:53 ½s¿è

¦^´_ 1# ¤p«L«È
  1. Option Explicit
  2. Public Rng As Range, Rng1 As Range, Rng2 As Range
  3. Sub Restart()
  4.     Sheets(1).Cells.Clear
  5. End Sub
  6. Sub Draw()
  7.     Dim B As Integer, C As Integer, d As Integer
  8.     With Sheet1
  9. L:
  10.         B = Int(100 * Rnd() + 1)
  11.         C = Application.CountIf(.Range("A:A"), B)       '¤ñ¹ï¬O§_­«´_
  12.         If C = 1 Then GoTo L:                           '­«°µ¶Ã¼Æ
  13.         d = Application.CountA(.Range("A:A")) + 5
  14.         .Cells(d, 1) = B
  15.         .Cells(d, 1).Select
  16.         Bingo (B)
  17.     End With
  18. End Sub
  19. Sub Paper()
  20.     Dim E As Range, B As Integer, i As Integer, ii As Integer
  21.     Set Rng = [Sheet1!I1:M5]                  '³]©w¼Æ¦r°Ï°ì
  22.     For Each E In Rng
  23. L:
  24.         B = Int(100 * Rnd() + 1)
  25.         C = Application.CountIf(Rng, B)        '¤ñ¹ï¬O§_­«´_
  26.         If C = 1 Then GoTo L:
  27.             E = B
  28.     Next
  29.     For i = 1 To 5                             '³]©w¹ï¨¤½u¥Ñ¥ª¦Ü¥k°Ï°ì
  30.         If i = 1 Then
  31.             Set Rng1 = Rng.Cells(i, i)
  32.         Else
  33.             Set Rng1 = Union(Rng1, Rng.Cells(i, i))
  34.         End If
  35.     Next
  36.     ii = 5
  37.     For i = 1 To 5                             '³]©w¹ï¨¤½u¥Ñ¥k¦Ü¥ª°Ï°ì
  38.         If i = 1 Then
  39.             Set Rng2 = Rng.Cells(i, ii)
  40.         Else
  41.             Set Rng2 = Union(Rng1, Rng.Cells(i, ii))
  42.         End If
  43.         ii = ii - 1
  44.     Next
  45. End Sub
  46. Sub Bingo(No As Integer)
  47.     Dim f As Range, d As Integer, C As Range, i As Integer, ii As Integer
  48.     Set f = Rng.Find(No, LookIn:=xlValues, LOOKAT:=xlWhole)     '´M§ä¼Æ¦r
  49.     If f Is Nothing Then Exit Sub
  50.     If Not f Is Nothing Then
  51.         f.Font.ColorIndex = 3              '§ä¨ì¼Æ¦rµ¹¦rÅéÃC¦â
  52.         f.Font.FontStyle = "²ÊÅé"           '§ä¨ì¼Æ¦rµ¹¦r«¬¼Ë¦¡
  53.     End If
  54.     For i = 1 To Rng.Columns.Count
  55.         d = 0
  56.         For Each C In Rng.Columns(i).Cells
  57.             If C.Font.ColorIndex = 3 Then d = d + 1
  58.         Next
  59.         If d = 5 Then Rng.Columns(i).Select: GoTo ok
  60.      Next
  61.     For i = 1 To Rng.Rows.Count                               'Àˬd¾î¦C
  62.         d = 0
  63.         For Each C In Rng.Rows(i).Cells
  64.             If C.Font.ColorIndex = 3 Then d = d + 1
  65.         Next
  66.         If d = 5 Then Rng.Rows(i).Select: GoTo ok
  67.     Next
  68.     d = 0
  69.     For Each C In Rng1                                          'Àˬd¹ï¨¤½u
  70.             If C.Font.ColorIndex = 3 Then d = d + 1
  71.     Next
  72.     If d = 5 Then Rng1.Select: GoTo ok
  73.     d = 0
  74.     For Each C In Rng2                                          'Àˬd¹ï¨¤½u
  75.             If C.Font.ColorIndex = 3 Then d = d + 1
  76.     Next
  77.     If d = 5 Then Rng2.Select: GoTo ok
  78. Exit Sub
  79. ok:
  80. MsgBox "Bingo"
  81. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¦³´¼¼z¤~¯à¤À¿ëµ½´c¨¸¥¿¡F¦³Á¾µê¤~¯à«Ø¥ß¬üº¡¤H¥Í¡C
ªð¦^¦Cªí ¤W¤@¥DÃD