Sudoku solver in Excel VBA

Update: You can download the Sudoku Solver in Excel with brute force here (latest version) here.

For the uninitiated, Sudoku is a grid of 9×9 cells where each cell can and must have a value from 1 to 9 such that no number must be repeated in a row, column or any of the 9 groups of 3×3 grids.

And not onto the circumstances behind this sudden urge to develop a sudoku solver. I had my wife beat me for the umpteenth time in Sudoku. Now I am not a bad loser, no sir, I can stand up and take a blow or two. But then my Sudoku solving skills seem to be making no progress and by the time she hands over a completed grid over to me, I STILL am usually found trying to get beyond the first half a dozen numbers :-(

Yesteday night I sat back and wrote a sudoku solver in excel using vba to solve the puzzles. It works…but only for some basic ones. In the process I *discovered* the steps to solve a Sudoku problem.

They are:
1. Row or Column hit – I : If a row or a column has only one cell left to fill, it must be the one not present in the row or column.
2. Grid hit : If a 3×3 grid has only one number to fill in, it must be the one not present in the grid.
3. Comparing the gird with rows and columns: If in any 3×3 grid any 2 out of 3 linear cells are non-empty and a particular number appears in the nearest two rows or columns (respectively), that number must fit the blank cell.

Grid, Row or Column Match

Grid, Row or Column Match

4. Elimination: For any particular cell in a row or column, if a particular number can not be placed in any of the other cells of that row or column, it MUST be placed in that cell.


Ideally using these four rules, one can try to loop till such time that no new nummbers can be added.

I think I am on the right track. The program works but only for a few Sudoku puzzles. I’m sure there’s a better way to achieve the results by using arrays in VBA but I’m too done to attempt that now!!!

In the meanshile, my wife still continues to beat me every single time !!!

Excel Formula, Excel Chart, Excel Macro, Excel VBA, Pivot Table Excel, Excel Dashboard

What Do You Think ?

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


Keep up with the latest stories - Delivered right to your inbox


English flagItalian flagKorean flagChinese (Simplified) flagPortuguese flagGerman flagFrench flagSpanish flagJapanese flagArabic flagRussian flagDutch flagHindi flagFilipino flagIndonesian flagThai flagTurkish flagPersian flag
treeemap software for excel