' Generates Magic Series of order 6
' Consecutive Prime Numbers
' Tested with Office 2007 under Windows 7
Sub MgcLns6()
Dim a(36), a1(6), b(500)
y = MsgBox("Blocked", vbExclamation, "MgcLns6")
End
a(1) = 67: a(2) = 71: a(3) = 73: a(4) = 79: a(5) = 83: a(6) = 89:
a(7) = 97: a(8) = 101: a(9) = 103: a(10) = 107: a(11) = 109: a(12) = 113:
a(13) = 127: a(14) = 131: a(15) = 137: a(16) = 139: a(17) = 149: a(18) = 151:
a(19) = 157: a(20) = 163: a(21) = 167: a(22) = 173: a(23) = 179: a(24) = 181:
a(25) = 191: a(26) = 193: a(27) = 197: a(28) = 199: a(29) = 211: a(30) = 223:
a(31) = 227: a(32) = 229: a(33) = 233: a(34) = 239: a(35) = 241: a(36) = 251:
s6 = 930: aMin = 67: aMax = 251
Erase b
For i1 = 1 To 36
b(a(i1)) = a(i1)
Next i1
Sheets("Klad1").Select
For j1 = 1 To 36
a1(1) = a(j1)
For j2 = j1 + 1 To 36
a1(2) = a(j2)
For j3 = j2 + 1 To 36
a1(3) = a(j3)
For j4 = j3 + 1 To 36
a1(4) = a(j4)
For j5 = j4 + 1 To 36
a1(5) = a(j5)
a1(6) = s6 - a1(1) - a1(2) - a1(3) - a1(4) - a1(5)
If a1(6) < aMin Or a1(6) > aMax Then GoTo 50
If b(a1(6)) <> a1(6) Then GoTo 50
If a1(6) <= a1(5) Then GoTo 50
n9 = n9 + 1
For i1 = 1 To 6
Cells(n9, i1).Value = a1(i1)
Next i1
50 Next j5
40 Next j4
30 Next j3
20 Next j2
10 Next j1
End Sub