Dim Chuc As Boolean
Sub Auto_open()
DongHo20
End Sub
' * * * * * * '
Sub DongHo20()
Dim SoGy As Double, iI As Integer
Sheets("S1").Select: SoGy = Timer
For iI = 19 To 0 Step -1
WSChange iI
Do
If Timer = SoGy + 1 Then
beep
SoGy = Timer: Exit Do
End If
Loop
Next iI
End Sub
' * * * * * * '
Sub WSChange(Targ As Integer)
Dim Clls As Range
If Targ < 10 Then
Chuc = True
Set Clls = Union(Range("B2:B6"), Range("D2:D6"), Cells(2, 3), Cells(6, 3))
Else
Chuc = False: Set Clls = Range("D2:D6")
Range("B2:C6").Interior.ColorIndex = 2
End If
ToMau Clls
Select Case Targ Mod 10
Case 0
Set Clls = Union(Range("F2:F6"), Range("H2:H6"))
ToMau Union(Clls, Cells(2, 7), Cells(6, 7))
Case 1
ToMau Range(Cells(2, 8), Cells(6, 8))
Case 2
Set Clls = Union(Range("H2:H4"), Range("F4:F6"), Range("G6:H6"))
ToMau Union(Clls, Cells(2, 7), Cells(4, 7))
Case 3
Set Clls = Union(Range("f2:h2"), Range("h3:h6"), Cells(4, 7))
ToMau Union(Clls, Range("f6:h6"))
Case 4
Set Clls = Union(Range("f2:f4"), Range("h2:h6"), Cells(4, 7))
ToMau Clls
Case 5
Set Clls = Union(Range("f2:g2"), Range("f4:h4"), Range("f6:h6"))
ToMau Union(Clls, Cells(3, 6), Cells(5, 8))
Case 6
Set Clls = Union(Range("f2:g2"), Range("f4:h4"), Range("f6:h6"))
ToMau Union(Clls, Cells(3, 6), Cells(5, 8), Cells(5, 6))
Case 7
Set Clls = Union(Range("h2:h6"), Cells(2, 7))
ToMau Clls
Case 8
Set Clls = Union(Range("f2:f6"), Range("h2:h6"), Cells(2, 7), Cells(4, 7))
ToMau Union(Clls, Cells(6, 7))
Case 9
Set Clls = Union(Range("h2:h6"), Range("f2:f4"), Cells(2, 7))
ToMau Union(Clls, Cells(4, 7))
End Select
End Sub
' * * * * * * '
Sub ToMau(Rng As Range)
Range("e2:H6").Interior.ColorIndex = 2
With Rng
.Interior.ColorIndex = IIf(Chuc, 3, 5)
End With
End Sub