here some code that will make you patient

Sub TakesTooLong()
Dim a As Long
Dim LeftVal As Long, Rightval As Long, val As Long
Dim PreviousPos As Long
Dim NotOk As Boolean
Dim RowCounter As Long
Dim ValStr As String
Application.ScreenUpdating = False
RowCounter = 1 'used for printing
For val = 11111111 To 88888888 'Asc("a")=97 (now=1), Asc("h")=104 (now=8)
ValStr = ""
NotOk = False
PreviousPos = -1
For a = 1 To 7
LeftVal = CLng(Mid(CStr(val), a, 1))
Rightval = CLng(Mid(CStr(val), a + 1, 1))
If LeftVal = 9 Or LeftVal = 0 Or Rightval = 9 Or Rightval = 0 Then
NotOk = True
Exit For 'only a-h equals 1-8 allowed
ElseIf LeftVal - Rightval = 0 Then 'The same
NotOk = True
Exit For
ElseIf Abs(LeftVal - Rightval) = 1 Then 'one char different
If a - PreviousPos = 1 Then 'two in a row
NotOk = True
Exit For
Else
PreviousPos = a
End If
End If
Next a
If Not NotOk Then
For a = 1 To 8
ValStr = ValStr & Chr(Mid(CStr(val), a, 1) + 96)
Next a
'Cells(Int(RowCounter / 100) + 1, RowCounter Mod 100 + 1) = ValStr
RowCounter = RowCounter + 1
End If
Next val
Application.ScreenUpdating = True
debug.print RowCounter & " Possibilities"
End Sub
Bookmarks