Sudoku Program Help

G

Gazza

I am trying to use excel to help solve the big SuperSudoku puzzles for
myself. I am OK with the algorythm but am not sure of the best way to
implement the code to carry out each stage of the process.

In particular I want a grid of six cells to be highlighted each time a
selection change takes place. Each of the sixteen cells represent the
possible candidates for the unique symbol that shall take their place. These
will be eliminated and the sixteen cells merged to contain the correct
symbol.
This is a section of what I mean as an example.

0 1 2 3 0 1 2 3 4 0 1 2 3
4 5 6 7 4 5 6 7 4 5 6 7
8 9 A B 8 9 A B 8 9 A B
C D E F C D E F C D E F
0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
4 5 6 7 4 5 6 7 4 5 6 7 4 5 6 7
8 9 A B 8 9 A B 8 9 A B 8 9 A B
C D E F C D E F C D E F C D E F
0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
4 5 6 7 4 5 6 7 4 5 6 7 4 5 6 7
8 9 A B 8 9 A B 8 9 A B 8 9 A B
C D E F C D E F C D E F C D E F


Do I use the command myRange.Offset(+X,X) or just some other form of
Range("A1:D4") to move the active range with the grid of 16 as shown? Any
suggestions appreciated.


Regards
Gary
 
A

Andibevan

Hi Gazza,

From my understanding of what you are asking I think that would be the best
solution. You can use the +x,x variables to move the grid around.

I am intrigued by this algorythm - have you got any more details? Sounds
interesting.

ATB

Andy
 
G

Gazza

Thanks Andi,

the algorythm will be working the following way:

When a known symbol is entered onto the grid, the associated row, column and
grid of 16 other symbols will be stepped through. Each of the 16 symbol
grids will contain 16 candidates for symbols. Each one of these will have
the corresponding symbol removed from its contents i.e. by process of
elimination, the main symbols cell of 16 candidates should be whittled down
to one eventually. So far I have only got at far as the plain english stage,
just trying to create it stage by stage with code so I can try out my ideas.
As for the complete solution of the puzzle I still have to work on that. For
now this part will speed up the elimination of candidates when the human
mind has decided what the symbol is to be entered.

Thanks again
Gazza
 
A

Andibevan

If you want to post your code I would be happy to provide some specific
guidance on putting the square onto the sheet........

Andi
 
G

Gazza

Here is my first "bash" as it were, at highlighting the 16 candidate cells
to give the impression of one cell. The only problem I have now is that I
have to use the mouse to select anything to the right and down because as
soon as a cursor key is pressed the code is run and the active cell is the
top left.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cRows As Long, cCols As Long
Dim myRange As Range
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This sub highlights a whole grid of 16 candidates when
'a selection is made using the mouse
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Application.EnableEvents = False
On Error GoTo ws_exit

Set myRange = Range("A1:b64")

cRows = Int((ActiveCell.Row + 3) / 4)
cCols = Int((ActiveCell.Column + 3) / 4)

Application.StatusBar = ""
Application.StatusBar = cRows & " " & cCols

cRows = 4 * (cRows - 1) + 1
cCols = 4 * (cCols - 1) + 1
Set myRange = Range("A1:D4")
myRange.Offset(cRows - 1, cCols - 1).Select

ws_exit:
Application.EnableEvents = True
End Sub

I now need a way of detecting that a key has been pressed i.e. a symbol has
been added. Then I can trigger the code to merge all the 16 cells to one and
make the newly entered symbol large enough to stand out.

Hope you got my meaning.

Regards
Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top