Sub WordSearch()
Dim puzzle As Object, Output As Object, grid As Variant, MaxCol As Long, MaxRow As Long
Dim dirs As Variant, dirx As Variant, diry As Variant
Dim r As Long, c As Long, d As Long, w As String, w2 As String
Dim resc As Long, i as long
Set puzzle = Range("A1:O20")
Set Output = Range("R1")
grid = puzzle.Value
MaxCol = UBound(grid, 2)
MaxRow = UBound(grid)
resc = 0
Output.Resize(1000, 3).ClearContents
Output.Resize(, 3) = Array("Word", "Start", "Direction")
dirs = Array("N", "NE", "E", "SE", "S", "SW", "W", "NW")
dirr = Array(-1, -1, 0, 1, 1, 1, 0, -1)
dirc = Array(0, 1, 1, 1, 0, -1, -1, -1)
For r = 1 To MaxRow
For c = 1 To MaxCol
Application.StatusBar = "Found: " & resc & " Checking " & puzzle.Cells(r, c).Address(0, 0)
For d = 0 To 7
w = GetWord(grid, r, c, d, dirs, dirr, dirc)
For i = 4 To Len(w)
w2 = Left(w, i)
If Application.CheckSpelling(w2) Then
resc = resc + 1
Output.Offset(resc) = w2
Output.Offset(resc, 1) = puzzle.Cells(r, c).Address(0, 0)
Output.Offset(resc, 2) = dirs(d)
DoEvents
End If
Next i
Next d
Next c
Next r
Application.StatusBar = False
If resc = 0 Then
MsgBox "No words found"
Exit Sub
End If
End Sub
Function GetWord(ByRef grid, ByVal r, ByVal c, ByRef d, ByRef dirs, ByRef dirr, ByRef dirc)
GetWord = ""
While r <= UBound(grid) And c <= UBound(grid, 2) And r > 0 And c > 0
GetWord = GetWord & LCase(grid(r, c))
r = r + dirr(d)
c = c + dirc(d)
Wend
End Function