## Shortest path

*Article updated on August 11, 2017*

I found a really interesting workbook that calculates the shortest distance from a start cell to an end cell. It is all made with excel formulas, not a single vba line! It uses a grid of 12 by 12 cells and the workbook is 11 MB.

He implemented Dijkstra's Algorithm to calculate the shortest path. If you are interested in how it works download his workbook.

I wanted to see if it was possible to make a bigger grid so I made a grid of 30 by 30 cells. The workbook quickly grew to 60 MB and there are 8 sheets. The maze is built by entering 1 for a wall cell. Conditional formatting then makes the cell black.

The animation below shows me deleting walls and the workbook instantly finds a new shorter path.

I also tried making an even larger grid, 65 x 65 but the workbook became too big. You can see my labyrinth here.

I guess this is a task for vba but that will be another post. [UPDATE] The follow up post is here: Finding the shortest path – A * pathfinding

### 3 Responses to “Shortest path”

### Leave a Reply

**How to add a formula to your comment:**

<code>your formula</code>

Remember to convert less than and larger than signs to html character entities before you post your comment.

**How to add VBA code to your comment:**

[vb 1="vbnet" language=","]

VBA code

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org

Add picture link to comment.

**Contact Oscar**

You can contact me through this webpage

Just curious how the cells change color without conditional formatting being supported in iWork Numbers. The spreadsheet works in Numbers, but I want to know which formula makes the cells change color.

[…] months ago I posted some interesting stuff I found: Shortest path. Let me explain, someone created a workbook that calculated the shortest path between a start cell […]

[…] Shortest path […]