-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExcel-Sudoku-Master-Solver_V2_Sheet(1)-Code.vb
87 lines (53 loc) · 1.55 KB
/
Excel-Sudoku-Master-Solver_V2_Sheet(1)-Code.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Option Explicit
'Clear button
Public Sub clear_Click()
Call clearSheet
End Sub
'Validate Button
Private Sub CommandButton1_Click()
Dim k As Integer
Dim j As Integer
'''''reset font size and color''''
k = 2
Do While (k <= 10)
j = 1
Do While (j <= 9)
Cells(k, j).Font.Size = 36
Cells(k, j).Font.Color = RGB(52, 131, 202)
j = j + 1
Loop
k = k + 1
Loop
'display valid board message
valMsg = True
'check if board is valid
Call ensureValid
End Sub
'SLO-MO button
Private Sub sloMo_Click()
If (Range(Cells(6, 10), Cells(6, 14)).Interior.Color = vbGreen) Then 'change red
Range(Cells(6, 10), Cells(6, 14)).Interior.Color = vbRed
Range("O11").Interior.Color = vbRed
Else 'change green
Range(Cells(6, 10), Cells(6, 14)).Interior.Color = vbGreen
Range("O11").Interior.Color = vbGreen
End If
End Sub
'Solves the Sudoku
Private Sub solve_Click()
Dim j As Integer
Dim k As Integer
'''''reset font size to ensure backtracking works''''
k = 2
Do While (k <= 10)
j = 1
Do While (j <= 9)
Cells(k, j).Font.Size = 36
Cells(k, j).Font.Color = RGB(52, 131, 202)
j = j + 1
Loop
k = k + 1
Loop
'call main function
Call runSolve
End Sub