So I'm doing a little experiment trying to make a pathfinding algorithm in an excel document.

I feel like everything should be in order here, but my if And Or statements in the middle of the loop return the error object reference required.

Is there anything you can see thats wrong here?

[CODE]
Sub MonsterMove()
Dim i As Integer, ws2 As Worksheet, ws3 As Worksheet, nRow As Long, nCol As Long, _
k As Integer, r As Integer, n As Range

Do Until health(r + 3) > 0
r = Int(4 * Rnd)
Loop

Set ws2 = Sheets("Sheet2")
Set ws3 = Sheets("Sheet3")
Set mapRange = Range("A1:J10")

ws3.Range("A1:J10") = " "
For i = 0 To 4
If enemyDistance(i) = 3 Then
Call MonsterAttack
End If
Next i

With ws3
.Cells(enemyRange(r).Row, enemyRange(r).Column) = 0
.Cells(location(r + 3).Row, location(r + 3).Column) = "n"

k = 0

.Cells(11, 11) = 0

Do Until .Cells(11, 11) = 1
For nRow = 1 To 10
For nCol = 1 To 10

If .Cells(nRow, nCol) = k Then

If ws2.Cells(nRow + 1, nCol) = 9 And (.Cells(nRow + 1, nCol) > k + 1 Or .Cells(nRow + 1, nCol) Is Null) Then
.Cells(nRow + 1, nCol) = k + 1
End If

If .Cells(nRow + 1, nCol) = "n" Then
.Cells(11, 11) = 1
End If

If ws2.Cells(nRow - 1, nCol) = 9 And .Cells(nRow - 1, nCol) > k + 1 Or .Cells(nRow - 1, nCol) Is Null Then
.Cells(nRow - 1, nCol) = k + 1
End If

If .Cells(nRow - 1, nCol) = "n" Then
.Cells(11, 11) = 1
End If

If ws2.Cells(nRow, nCol + 1) = 9 And .Cells(nRow, nCol + 1) > k + 1 Or .Cells(nRow, nCol + 1) Is Null Then
.Cells(nRow, nCol + 1) = k + 1
End If

If .Cells(nRow, nCol + 1) = "n" Then
.Cells(11, 11) = 1
End If

If ws2.Cells(nRow, nCol - 1) = 9 And .Cells(nRow, nCol - 1) > k + 1 Or .Cells(nRow, nCol - 1) Is Null Then
.Cells(nRow, nCol - 1) = k + 1
End If

If .Cells(nRow, nCol - 1) = "n" Then
.Cells(11, 11) = 1
End If

End If

Next nCol
Next nRow
k = k + 1
Loop

End With

End Sub