'Maybe this isn't possible but does anybobdy know how to highlight the cells that come up as a "problem"
CODE
Option Explicit
Sub Sudokutest()
Dim row As Integer
Dim col As Integer
Dim I As Integer
Dim IsBlank As Variant
Dim CellValue As Integer
Dim foundone As String
Dim foundtwo As String
Dim foundthree As String
Dim foundfour As String
Dim foundfive As String
Dim foundsix As String
Dim foundseven As String
Dim foundeight As String
Dim foundnine As String
Dim problem As Variant 'not sure if it is an integer or string
Dim Sec1 As Integer
'Checks columns for errors
col = 1
For col = 1 To 9
For I = 1 To 9
CellValue = Cells(I, col).Value
Select Case CellValue
Case 1
If foundone = "yes" Then
problem = "yes"
Else
foundone = "yes"
End If
Case 2
If foundtwo = "yes" Then
problem = "yes"
Else
foundtwo = "yes"
End If
Case 3
If foundthree = "yes" Then
problem = "yes"
Else
foundthree = "yes"
End If
Case 4
If foundfour = "yes" Then
problem = "yes"
Else
foundfour = "yes"
End If
Case 5
If foundfive = "yes" Then
problem = "yes"
Else
foundfive = "yes"
End If
Case 6
If foundsix = "yes" Then
problem = "yes"
Else
foundsix = "yes"
End If
Case 7
If foundseven = "yes" Then
problem = "yes"
Else
foundseven = "yes"
End If
Case 8
If foundeight = "yes" Then
problem = "yes"
Else
foundeight = "yes"
End If
Case 9
If foundnine = "yes" Then
problem = "yes"
Else
foundnine = "yes"
End If
End Select
If problem = "yes" Then
MsgBox ("You have a repeated number in a cell")
Cells("").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Exit For
End If
Next I
'reset all found variables
CellValue = 0
foundone = "no"
foundtwo = "no"
foundthree = "no"
foundfour = "no"
foundfive = "no"
foundsix = "no"
foundseven = "no"
foundeight = "no"
foundnine = "no"
MsgBox "done with column" & col
Next col
'Check Rows for errors
row = 1
For row = 1 To 9
For I = 1 To 9
CellValue = Cells(row, I).Value
Select Case CellValue
Case 1
If foundone = "yes" Then
problem = "yes"
Else
foundone = "yes"
End If
Case 2
If foundtwo = "yes" Then
problem = "yes"
Else
foundtwo = "yes"
End If
Case 3
If foundthree = "yes" Then
problem = "yes"
Else
foundthree = "yes"
End If
Case 4
If foundfour = "yes" Then
problem = "yes"
Else
foundfour = "yes"
End If
Case 5
If foundfive = "yes" Then
problem = "yes"
Else
foundfive = "yes"
End If
Case 6
If foundsix = "yes" Then
problem = "yes"
Else
foundsix = "yes"
End If
Case 7
If foundseven = "yes" Then
problem = "yes"
Else
foundseven = "yes"
End If
Case 8
If foundeight = "yes" Then
problem = "yes"
Else
foundeight = "yes"
End If
Case 9
If foundnine = "yes" Then
problem = "yes"
Else
foundnine = "yes"
End If
End Select
If problem = "yes" Then
MsgBox ("You have a repeated number in a row")
Cell.Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Exit For
End If
Next I
'reset all found variables
CellValue = 0
foundone = "no"
foundtwo = "no"
foundthree = "no"
foundfour = "no"
foundfive = "no"
foundsix = "no"
foundseven = "no"
foundeight = "no"
foundnine = "no"
MsgBox "done with row" & row
Next row
End Sub
edit: added [code] tags ~ jayman9