Coye Gracias por su ayuda, yo le he estado dando a ver si me sale pero hasta ahora he logrado que programe las casillas del 1 al 9 sin que se repitan en cada una de las matrices. El programa con la funcion Rnd rellena el tablero haciendo que se cumplan estas 2 condiciones 2 veces, la tercera vez se cuelga, no se ahi les paso el codigo a ver que me dicen
---------------------------------------------------------------
Dim A(1 To 9, 1 To 9) As Byte, B(0 To 8) As Byte, C(1 To 9) As Byte, Numero As Byte, Sec2 As String
Dim I As Single, J As Single, Sec As String, Digito As Byte, S As String, K As Byte, M As String, P As String
Dim Sec1 As String, Sec3 As String, Bandera As Boolean
-------------------------------------------------
Private Sub Genera_Matriz()
Sec2 = "" 'Como no se muede inicializar una variable tipo Strign en "0" se inicializa en ""(vacio)
For K = 0 To N - 1
Bandera = True
With GridY
.RowHeight(K) = 900
Sec = ""
Sec1 = IIf((K Mod 3) = 0, "", Sec1)
Sec2 = IIf((K Mod 3) = 0, "", Sec2)
Sec3 = IIf((K Mod 3) = 0, "", Sec3)
For I = 3 * Int(K / 3) To 3 * Int(K / 3) + 2 'para que recorra las filas se le cambia
For J = 3 * (K Mod 3) To 3 * (K Mod 3) + 2
Digito = Int(N * Rnd + 1) 'del 1 al 9
If InStr(Sec, CStr(Digito)) = 0 Then 'CStr conviete Digito a tipo String
Sec = Sec & Digito
'CVar devuelve Digito de tipo String a tipo anterior, en este caso a tipo byte
Select Case I
Case Is = 0, 3, 6
If InStr(Sec1, CStr(Digito)) = 0 Then
Sec1 = Sec1 & Digito
A(I + 1, J + 1) = CVar(Digito)
Else
Sec = Mid(Sec, 1, Len(Sec) - 1)
J = J - 1
End If
Case Is = 1, 4, 7
If InStr(Sec2, CStr(Digito)) = 0 Then
Sec2 = Sec2 & Digito
A(I + 1, J + 1) = CVar(Digito)
Else
Sec = Mid(Sec, 1, Len(Sec) - 1)
J = J - 1
End If
Case Is = 2, 5, 8
If InStr(Sec3, CStr(Digito)) = 0 Then
Sec3 = Sec3 & Digito
A(I + 1, J + 1) = CVar(Digito)
Else
Select Case K
Case Is = 0, 3, 6
J = J - 1
Case Is = 1, 2, 4, 6, 7
Bandera = False
Select Case J
Case Is = 4, 7
Sec1 = Mid(Sec1, 1, Len(Sec1) - 3)
Sec2 = Mid(Sec2, 1, Len(Sec2) - 3)
Sec3 = Mid(Sec3, 1, Len(Sec3) - 1)
Case Is = 5, 8
Sec1 = Mid(Sec1, 1, Len(Sec1) - 3)
Sec2 = Mid(Sec2, 1, Len(Sec2) - 3)
Sec3 = Mid(Sec3, 1, Len(Sec3) - 2)
End Select
End Select
End If
End Select
Else
J = J - 1
End If
Next J
Next I
End With
Llena_MatrizA
If Bandera = False Then K = K - 1
Next K
End Sub
Const N = 9