' Generates Prime Number Composed Magic Squares of order 18
' Overlapping Sub Squares, Center Square order 6
' Tested with Office 365 under Windows 10
Sub Priem14g()
Dim a1(1142), a(324), a18(324), b1(43300), b(43300), c(324), d2(2)
y = MsgBox("Locked", vbCritical, "Routine Priem14g")
End
Sheets("Klad1").Select
n5 = 0: n9 = 0: k1 = 1: k2 = 1
ShtNm1 = "Pairs8"
ShtNm2 = "SymLns14"
t1 = Timer
For j100 = 36 To 52
y = MsgBox(CStr(j100), 1, "Test")
If y = 2 Then End
GoSub 1500: If fl1 = 0 Then GoTo 1000 'Define Variables
' Complete Eccentrc Squares F1/2 (6 x 6)
d2(1) = a18(40) + a18(57)
d2(2) = a18(285) + a18(268)
For n10 = 1 To 2
Erase a, b, c
GoSub 5000: If fl1 = 0 Then GoTo 1000
Select Case n10
Case 1:
a18(1) = a(8): a18(2) = a(7): a18(3) = a(6): a18(4) = a(5): a18(5) = a(2): a18(6) = a(1):
a18(19) = a(16): a18(20) = a(15): a18(21) = a(14): a18(22) = a(13): a18(23) = a(10): a18(24) = a(9):
a18(37) = a(22): a18(38) = a(21):
a18(55) = a(24): a18(56) = a(23):
a18(73) = a(26): a18(74) = a(25):
a18(91) = a(28): a18(92) = a(27):
n32 = 28: GoSub 900 'Remove used integers from available integers
Case 2:
a18(233) = a(27): a18(234) = a(28):
a18(251) = a(25): a18(252) = a(26):
a18(269) = a(23): a18(270) = a(24):
a18(287) = a(21): a18(288) = a(22):
a18(301) = a(9): a18(302) = a(10): a18(303) = a(13): a18(304) = a(14): a18(305) = a(15): a18(306) = a(16):
a18(319) = a(1): a18(320) = a(2): a18(321) = a(5): a18(322) = a(6): a18(323) = a(7): a18(324) = a(8):
n32 = 28: GoSub 900 'Remove used integers from available integers
End Select
Next n10
' Complete Eccentrc Squares D1/2 (12 x 12)
d2(1) = a18(45) + a18(64) + a18(83) + a18(102) + a18(121) + a18(140) + a18(159) + a18(178)
d2(2) = a18(147) + a18(166) + a18(185) + a18(204) + a18(223) + a18(242) + a18(261) + a18(280)
For n10 = 1 To 2
Erase a, b, c
GoSub 7000: If fl1 = 0 Then GoTo 1000
Select Case n10
Case 1:
a18(7) = a(1): a18(8) = a(2): a18(9) = a(3): a18(10) = a(4): a18(11) = a(5): a18(12) = a(6):
a18(13) = a(7): a18(14) = a(37): a18(15) = a(38): a18(16) = a(8): a18(17) = a(9): a18(18) = a(10):
a18(25) = a(11): a18(26) = a(12): a18(27) = a(13): a18(28) = a(14): a18(29) = a(15): a18(30) = a(16):
a18(31) = a(17): a18(32) = a(39): a18(33) = a(40): a18(34) = a(18): a18(35) = a(19): a18(36) = a(20):
a18(53) = a(21): a18(54) = a(22):
a18(71) = a(23): a18(72) = a(24):
a18(89) = a(25): a18(90) = a(26):
a18(107) = a(27): a18(108) = a(28):
a18(125) = a(29): a18(126) = a(30):
a18(143) = a(41): a18(144) = a(42):
a18(161) = a(43): a18(162) = a(44):
a18(179) = a(31): a18(180) = a(32):
a18(197) = a(33): a18(198) = a(34):
a18(215) = a(35): a18(216) = a(36):
n32 = 44: GoSub 900 'Remove used integers from available integers
Case 2:
a18(109) = a(36): a18(110) = a(35):
a18(127) = a(34): a18(128) = a(33):
a18(145) = a(32): a18(146) = a(31):
a18(163) = a(44): a18(164) = a(43):
a18(181) = a(42): a18(182) = a(41):
a18(199) = a(30): a18(200) = a(29):
a18(217) = a(28): a18(218) = a(27):
a18(235) = a(26): a18(236) = a(25):
a18(253) = a(24): a18(254) = a(23):
a18(271) = a(22): a18(272) = a(21):
a18(289) = a(20): a18(290) = a(19): a18(291) = a(18): a18(292) = a(40): a18(293) = a(39): a18(294) = a(17):
a18(295) = a(16): a18(296) = a(15): a18(297) = a(14): a18(298) = a(13): a18(299) = a(12): a18(300) = a(11):
a18(307) = a(10): a18(308) = a(9): a18(309) = a(8): a18(310) = a(38): a18(311) = a(37): a18(312) = a(7):
a18(313) = a(6): a18(314) = a(5): a18(315) = a(4): a18(316) = a(3): a18(317) = a(2): a18(318) = a(1):
n32 = 44: GoSub 900 'Remove used integers from available integers
End Select
Next n10
500
GoSub 800 'Double Check Identical Integers a18()
If fl1 = 1 Then
n9 = n9 + 1: GoSub 650 'Print Composed Squares a18()
End If
1000 Erase b1, b, c
Next j100
t2 = Timer
t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions"
y = MsgBox(t10, 0, "Routine Priem14g")
End
' Complete Eccentrc Squares F1/2 (6 x 6)
5000 fl1 = 1
' Determine Main Diagonal and related pairs
For j1 = m1 To m2
If b1(a1(j1)) = 0 Then GoTo 10
If b(a1(j1)) = 0 Then b(a1(j1)) = a1(j1): c(1) = a1(j1) Else GoTo 10
a(1) = a1(j1)
a(9) = Pr4 - a(1): If b(a(9)) = 0 Then b(a(9)) = a(9): c(9) = a(9) Else GoTo 90
For j2 = m2 To m1 Step -1
If b1(a1(j2)) = 0 Then GoTo 20
If b(a1(j2)) = 0 Then b(a1(j2)) = a1(j2): c(2) = a1(j2) Else GoTo 20
a(2) = a1(j2)
a(10) = Pr4 - a(2): If b(a(10)) = 0 Then b(a(10)) = a(10): c(10) = a(10) Else GoTo 100
For j25 = m1 To m2
If b1(a1(j25)) = 0 Then GoTo 250
If b(a1(j25)) = 0 Then b(a1(j25)) = a1(j25): c(25) = a1(j25) Else GoTo 250
a(25) = a1(j25)
a(26) = Pr4 - a(25): If b(a(26)) = 0 Then b(a(26)) = a(26): c(26) = a(26) Else GoTo 260
a(28) = s6 - d2(n10) - a(25) - a(10) - a(1)
If a(28) < a1(m1) Or a(28) > a1(m2) Then GoTo 280:
If b1(a(28)) = 0 Then GoTo 280
If b(a(28)) = 0 Then b(a(28)) = a(28): c(28) = a(28) Else GoTo 280
a(27) = Pr4 - a(28): If b(a(27)) = 0 Then b(a(27)) = a(27): c(27) = a(27) Else GoTo 270
' Determine remainder of the pairs
For j7 = m1 To m2
If b1(a1(j7)) = 0 Then GoTo 70
If b(a1(j7)) = 0 Then b(a1(j7)) = a1(j7): c(7) = a1(j7) Else GoTo 70
a(7) = a1(j7)
a(16) = Pr4 - a(7): If b(a(16)) = 0 Then b(a(16)) = a(16): c(16) = a(16) Else GoTo 160
For j8 = m2 To m1 Step -1
If b1(a1(j8)) = 0 Then GoTo 80
If b(a1(j8)) = 0 Then b(a1(j8)) = a1(j8): c(8) = a1(j8) Else GoTo 80
a(8) = a1(j8)
a(15) = Pr4 - a(8): If b(a(15)) = 0 Then b(a(15)) = a(15): c(15) = a(15) Else GoTo 150
For j5 = m1 To m2
If b1(a1(j5)) = 0 Then GoTo 50
If b(a1(j5)) = 0 Then b(a1(j5)) = a1(j5): c(5) = a1(j5) Else GoTo 50
a(5) = a1(j5)
a(13) = Pr4 - a(5): If b(a(13)) = 0 Then b(a(13)) = a(13): c(13) = a(13) Else GoTo 130
a(6) = s6 - a(1) - a(2) - a(5) - a(7) - a(8)
If a(6) < a1(m1) Or a(6) > a1(m2) Then GoTo 60:
If b1(a(6)) = 0 Then GoTo 60
If b(a(6)) = 0 Then b(a(6)) = a(6): c(6) = a(6) Else GoTo 60
a(14) = Pr4 - a(6): If b(a(14)) = 0 Then b(a(14)) = a(14): c(14) = a(14) Else GoTo 140
For j21 = m2 To m1 Step -1
If b1(a1(j21)) = 0 Then GoTo 210
If b(a1(j21)) = 0 Then b(a1(j21)) = a1(j21): c(21) = a1(j21) Else GoTo 210
a(21) = a1(j21)
a(22) = Pr4 - a(21): If b(a(22)) = 0 Then b(a(22)) = a(22): c(22) = a(22) Else GoTo 220
a(23) = s6 - a(7) - a(15) - a(21) - a(25) - a(27)
If a(23) < a1(m1) Or a(23) > a1(m2) Then GoTo 230:
If b1(a(23)) = 0 Then GoTo 230
If b(a(23)) = 0 Then b(a(23)) = a(23): c(23) = a(23) Else GoTo 230
a(24) = Pr4 - a(23): If b(a(24)) = 0 Then b(a(24)) = a(24): c(24) = a(24) Else GoTo 240
Return
b(c(24)) = 0: c(24) = 0
240 b(c(23)) = 0: c(23) = 0
230 b(c(22)) = 0: c(22) = 0
220 b(c(21)) = 0: c(21) = 0
210 Next j21
b(c(14)) = 0: c(14) = 0
140 b(c(6)) = 0: c(6) = 0
60 b(c(13)) = 0: c(13) = 0
130 b(c(5)) = 0: c(5) = 0
50 Next j5
b(c(15)) = 0: c(15) = 0
150 b(c(8)) = 0: c(8) = 0
80 Next j8
b(c(16)) = 0: c(16) = 0
160 b(c(7)) = 0: c(7) = 0
70 Next j7
b(c(27)) = 0: c(27) = 0
270 b(c(28)) = 0: c(28) = 0
280 b(c(26)) = 0: c(26) = 0
260 b(c(25)) = 0: c(25) = 0
250 Next j25
b(c(10)) = 0: c(10) = 0
100 b(c(2)) = 0: c(2) = 0
20 Next j2
b(c(9)) = 0: c(9) = 0
90 b(c(1)) = 0: c(1) = 0
10 Next j1
fl1 = 0
Return
' Complete Eccentrc Squares D1/2 (12 x 12)
7000 fl1 = 1
' Determine Main Diagonal and related pairs
For j1 = m1 To m2
If b1(a1(j1)) = 0 Then GoTo 7010
If b(a1(j1)) = 0 Then b(a1(j1)) = a1(j1): c(1) = a1(j1) Else GoTo 7010
a(1) = a1(j1)
a(11) = Pr4 - a(1): If b(a(11)) = 0 Then b(a(11)) = a(11): c(11) = a(11) Else GoTo 7110
For j2 = m2 To m1 Step -1
If b1(a1(j2)) = 0 Then GoTo 7020
If b(a1(j2)) = 0 Then b(a1(j2)) = a1(j2): c(2) = a1(j2) Else GoTo 7020
a(2) = a1(j2)
a(12) = Pr4 - a(2): If b(a(12)) = 0 Then b(a(12)) = a(12): c(12) = a(12) Else GoTo 7120
For j33 = m1 To m2
If b1(a1(j33)) = 0 Then GoTo 7330
If b(a1(j33)) = 0 Then b(a1(j33)) = a1(j33): c(33) = a1(j33) Else GoTo 7330
a(33) = a1(j33)
a(34) = Pr4 - a(33): If b(a(34)) = 0 Then b(a(34)) = a(34): c(34) = a(34) Else GoTo 7340
'' For j36 = m1 To m2
'' If b1(a1(j36)) = 0 Then GoTo 7360
'' If b(a1(j36)) = 0 Then b(a1(j36)) = a1(j36): c(36) = a1(j36) Else GoTo 7360
'' a(36) = a1(j36)
a(36) = s12 - d2(n10) - a(33) - a(12) - a(1)
If a(36) < a1(m1) Or a(36) > a1(m2) Then GoTo 7360:
If b1(a(36)) = 0 Then GoTo 7360
If b(a(36)) = 0 Then b(a(36)) = a(36): c(36) = a(36) Else GoTo 7360
a(35) = Pr4 - a(36): If b(a(35)) = 0 Then b(a(35)) = a(35): c(35) = a(35) Else GoTo 7350
' Determine remainder of the pairs
For j3 = m2 To m1 Step -1
If b1(a1(j3)) = 0 Then GoTo 7030
If b(a1(j3)) = 0 Then b(a1(j3)) = a1(j3): c(3) = a1(j3) Else GoTo 7030
a(3) = a1(j3)
a(13) = Pr4 - a(3): If b(a(13)) = 0 Then b(a(13)) = a(13): c(13) = a(13) Else GoTo 7130
For j4 = m1 To m2
If b1(a1(j4)) = 0 Then GoTo 7040
If b(a1(j4)) = 0 Then b(a1(j4)) = a1(j4): c(4) = a1(j4) Else GoTo 7040
a(4) = a1(j4)
a(14) = Pr4 - a(4): If b(a(14)) = 0 Then b(a(14)) = a(14): c(14) = a(14) Else GoTo 7140
For j5 = m2 To m1 Step -1
If b1(a1(j5)) = 0 Then GoTo 7050
If b(a1(j5)) = 0 Then b(a1(j5)) = a1(j5): c(5) = a1(j5) Else GoTo 7050
a(5) = a1(j5)
a(15) = Pr4 - a(5): If b(a(15)) = 0 Then b(a(15)) = a(15): c(15) = a(15) Else GoTo 7150
For j6 = m1 To m2
If b1(a1(j6)) = 0 Then GoTo 7060
If b(a1(j6)) = 0 Then b(a1(j6)) = a1(j6): c(6) = a1(j6) Else GoTo 7060
a(6) = a1(j6)
a(16) = Pr4 - a(6): If b(a(16)) = 0 Then b(a(16)) = a(16): c(16) = a(16) Else GoTo 7160
For j7 = m2 To m1 Step -1
If b1(a1(j7)) = 0 Then GoTo 7070
If b(a1(j7)) = 0 Then b(a1(j7)) = a1(j7): c(7) = a1(j7) Else GoTo 7070
a(7) = a1(j7)
a(17) = Pr4 - a(7): If b(a(17)) = 0 Then b(a(17)) = a(17): c(17) = a(17) Else GoTo 7170
For j9 = m2 To m1 Step -1
If b1(a1(j9)) = 0 Then GoTo 7090
If b(a1(j9)) = 0 Then b(a1(j9)) = a1(j9): c(9) = a1(j9) Else GoTo 7090
a(9) = a1(j9)
a(20) = Pr4 - a(9): If b(a(20)) = 0 Then b(a(20)) = a(20): c(20) = a(20) Else GoTo 7200
For j10 = m1 To m2
If b1(a1(j10)) = 0 Then GoTo 7100
If b(a1(j10)) = 0 Then b(a1(j10)) = a1(j10): c(10) = a1(j10) Else GoTo 7100
a(10) = a1(j10)
a(19) = Pr4 - a(10): If b(a(19)) = 0 Then b(a(19)) = a(19): c(19) = a(19) Else GoTo 7190
For j37 = m1 To m2
If b1(a1(j37)) = 0 Then GoTo 7370
If b(a1(j37)) = 0 Then b(a1(j37)) = a1(j37): c(37) = a1(j37) Else GoTo 7370
a(37) = a1(j37)
a(39) = Pr4 - a(37): If b(a(39)) = 0 Then b(a(39)) = a(39): c(39) = a(39) Else GoTo 7390
For j38 = m2 To m1 Step -1
If b1(a1(j38)) = 0 Then GoTo 7380
If b(a1(j38)) = 0 Then b(a1(j38)) = a1(j38): c(38) = a1(j38) Else GoTo 7380
a(38) = a1(j38)
a(40) = Pr4 - a(38): If b(a(40)) = 0 Then b(a(40)) = a(40): c(40) = a(40) Else GoTo 7400
a(8) = s12 - a(1) - a(2) - a(3) - a(4) - a(5) - a(6) - a(7) - a(9) - a(10) - a(37) - a(38)
If a(8) < a1(m1) Or a(8) > a1(m2) Then GoTo 7080:
If b1(a(8)) = 0 Then GoTo 7080
If b(a(8)) = 0 Then b(a(8)) = a(8): c(8) = a(8) Else GoTo 7080
a(18) = Pr4 - a(8): If b(a(18)) = 0 Then b(a(18)) = a(18): c(18) = a(18) Else GoTo 7180
For j21 = m2 To m1 Step -1
If b1(a1(j21)) = 0 Then GoTo 7210
If b(a1(j21)) = 0 Then b(a1(j21)) = a1(j21): c(21) = a1(j21) Else GoTo 7210
a(21) = a1(j21)
a(22) = Pr4 - a(21): If b(a(22)) = 0 Then b(a(22)) = a(22): c(22) = a(22) Else GoTo 7220
For j23 = m1 To m2
If b1(a1(j23)) = 0 Then GoTo 7230
If b(a1(j23)) = 0 Then b(a1(j23)) = a1(j23): c(23) = a1(j23) Else GoTo 7230
a(23) = a1(j23)
a(24) = Pr4 - a(23): If b(a(24)) = 0 Then b(a(24)) = a(24): c(24) = a(24) Else GoTo 7240
For j25 = m2 To m1 Step -1
If b1(a1(j25)) = 0 Then GoTo 7250
If b(a1(j25)) = 0 Then b(a1(j25)) = a1(j25): c(25) = a1(j25) Else GoTo 7250
a(25) = a1(j25)
a(26) = Pr4 - a(25): If b(a(26)) = 0 Then b(a(26)) = a(26): c(26) = a(26) Else GoTo 7260
For j27 = m1 To m2
If b1(a1(j27)) = 0 Then GoTo 7270
If b(a1(j27)) = 0 Then b(a1(j27)) = a1(j27): c(27) = a1(j27) Else GoTo 7270
a(27) = a1(j27)
a(28) = Pr4 - a(27): If b(a(28)) = 0 Then b(a(28)) = a(28): c(28) = a(28) Else GoTo 7280
For j29 = m2 To m1 Step -1
If b1(a1(j29)) = 0 Then GoTo 7290
If b(a1(j29)) = 0 Then b(a1(j29)) = a1(j29): c(29) = a1(j29) Else GoTo 7290
a(29) = a1(j29)
a(30) = Pr4 - a(29): If b(a(30)) = 0 Then b(a(30)) = a(30): c(30) = a(30) Else GoTo 7300
For j41 = m1 To m2
If b1(a1(j41)) = 0 Then GoTo 7410
If b(a1(j41)) = 0 Then b(a1(j41)) = a1(j41): c(41) = a1(j41) Else GoTo 7410
a(41) = a1(j41)
a(42) = Pr4 - a(41): If b(a(42)) = 0 Then b(a(42)) = a(42): c(42) = a(42) Else GoTo 7420
For j43 = m2 To m1 Step -1
If b1(a1(j43)) = 0 Then GoTo 7430
If b(a1(j43)) = 0 Then b(a1(j43)) = a1(j43): c(43) = a1(j43) Else GoTo 7430
a(43) = a1(j43)
a(44) = Pr4 - a(43): If b(a(44)) = 0 Then b(a(44)) = a(44): c(44) = a(44) Else GoTo 7440
a(31) = s12 - a(9) - a(19) - a(21) - a(23) - a(25) - a(27) - a(29) - a(33) - a(35) - a(41) - a(43)
If a(31) < a1(m1) Or a(31) > a1(m2) Then GoTo 7310:
If b1(a(31)) = 0 Then GoTo 7310
If b(a(31)) = 0 Then b(a(31)) = a(31): c(31) = a(31) Else GoTo 7310
a(32) = Pr4 - a(31): If b(a(32)) = 0 Then b(a(32)) = a(32): c(32) = a(32) Else GoTo 7320
Return
b(c(32)) = 0: c(32) = 0
7320 b(c(31)) = 0: c(31) = 0
7310
b(c(44)) = 0: c(44) = 0
7440 b(c(43)) = 0: c(43) = 0
7430 Next j43
b(c(42)) = 0: c(42) = 0
7420 b(c(41)) = 0: c(41) = 0
7410 Next j41
b(c(30)) = 0: c(30) = 0
7300 b(c(29)) = 0: c(29) = 0
7290 Next j29
b(c(28)) = 0: c(28) = 0
7280 b(c(27)) = 0: c(27) = 0
7270 Next j27
b(c(26)) = 0: c(26) = 0
7260 b(c(25)) = 0: c(25) = 0
7250 Next j25
b(c(24)) = 0: c(24) = 0
7240 b(c(23)) = 0: c(23) = 0
7230 Next j23
b(c(22)) = 0: c(22) = 0
7220 b(c(21)) = 0: c(21) = 0
7210 Next j21
b(c(18)) = 0: c(18) = 0
7180 b(c(8)) = 0: c(8) = 0
7080
b(c(40)) = 0: c(40) = 0
7400 b(c(38)) = 0: c(38) = 0
7380 Next j38
b(c(39)) = 0: c(39) = 0
7390 b(c(37)) = 0: c(37) = 0
7370 Next j37
b(c(19)) = 0: c(19) = 0
7190 b(c(10)) = 0: c(10) = 0
7100 Next j10
b(c(20)) = 0: c(20) = 0
7200 b(c(9)) = 0: c(9) = 0
7090 Next j9
b(c(17)) = 0: c(17) = 0
7170 b(c(7)) = 0: c(7) = 0
7070 Next j7
b(c(16)) = 0: c(16) = 0
7160 b(c(6)) = 0: c(6) = 0
7060 Next j6
b(c(15)) = 0: c(15) = 0
7150 b(c(5)) = 0: c(5) = 0
7050 Next j5
b(c(14)) = 0: c(14) = 0
7140 b(c(4)) = 0: c(4) = 0
7040 Next j4
b(c(13)) = 0: c(13) = 0
7130 b(c(3)) = 0: c(3) = 0
7030 Next j3
b(c(35)) = 0: c(35) = 0
7350 b(c(36)) = 0: c(36) = 0
7360 ''Next j36
b(c(34)) = 0: c(34) = 0
7340 b(c(33)) = 0: c(33) = 0
7330 Next j33
b(c(12)) = 0: c(12) = 0
7120 b(c(2)) = 0: c(2) = 0
7020 Next j2
b(c(11)) = 0: c(11) = 0
7110 b(c(1)) = 0: c(1) = 0
7010 Next j1
fl1 = 0
Return
' Define Variables
1500 fl1 = 1
' Start Reading Data ShtNm2
Rcrd1a = Sheets(ShtNm2).Cells(j100, 199).Value
MC14 = Sheets(ShtNm2).Cells(j100, 197).Value
' Read Prime Numbers From Sheet ShtNm1
Pr4 = Sheets(ShtNm1).Cells(Rcrd1a, 1).Value 'PairSum
s4 = 2 * Pr4 'MC4
s6 = 3 * Pr4 'MC6
s8 = 2 * s4
s10 = 5 * Pr4 'MC10
s12 = 6 * Pr4 'MC12
s14 = 7 * Pr4 'MC14
s18 = 9 * Pr4 'MC18
nVar = Sheets(ShtNm1).Cells(Rcrd1a, 5).Value
If nVar < 324 Then fl1 = 0: Return
If MC14 <> s14 Then
y = MsgBox("Conflict in Data", vbCritical, "Read " + ShtNm2)
End
End If
Erase b1
For j1 = 1 To nVar
x = Sheets(ShtNm1).Cells(Rcrd1a, 6 + j1).Value
b1(x) = x
Next j1
pmax = Sheets(ShtNm1).Cells(Rcrd1a, 6 + nVar).Value
' Read Embedded Square 14 x 14
Erase a
For i1 = 1 To 196
a(i1) = Sheets(ShtNm2).Cells(j100, i1).Value
Next i1
n32 = 196: GoSub 900 'Remove used primes from available primes
Erase a18
GoSub 700 'Assign Center Square
Erase a
' Restore available pairs in a1()
n10 = 0
For j1 = 1 To pmax
If b1(j1) <> 0 Then
n10 = n10 + 1
a1(n10) = b1(j1)
End If
Next j1
m1 = 1: m2 = n10: n10 = 0
If a1(1) = 1 Then m1 = 2: m2 = m2 - 1
Return
' Assign Center Square
700
a18(39) = a(1): a18(40) = a(2): a18(41) = a(3): a18(42) = a(4): a18(43) = a(5):
a18(44) = a(6): a18(45) = a(7): a18(46) = a(8): a18(47) = a(9): a18(48) = a(10):
a18(49) = a(11): a18(50) = a(12): a18(51) = a(13): a18(52) = a(14):
a18(57) = a(15): a18(58) = a(16): a18(59) = a(17): a18(60) = a(18): a18(61) = a(19):
a18(62) = a(20): a18(63) = a(21): a18(64) = a(22): a18(65) = a(23): a18(66) = a(24):
a18(67) = a(25): a18(68) = a(26): a18(69) = a(27): a18(70) = a(28):
a18(75) = a(29): a18(76) = a(30): a18(77) = a(31): a18(78) = a(32): a18(79) = a(33):
a18(80) = a(34): a18(81) = a(35): a18(82) = a(36): a18(83) = a(37): a18(84) = a(38):
a18(85) = a(39): a18(86) = a(40): a18(87) = a(41): a18(88) = a(42):
a18(93) = a(43): a18(94) = a(44): a18(95) = a(45): a18(96) = a(46): a18(97) = a(47):
a18(98) = a(48): a18(99) = a(49): a18(100) = a(50): a18(101) = a(51): a18(102) = a(52):
a18(103) = a(53): a18(104) = a(54): a18(105) = a(55): a18(106) = a(56):
a18(111) = a(57): a18(112) = a(58): a18(113) = a(59): a18(114) = a(60): a18(115) = a(61):
a18(116) = a(62): a18(117) = a(63): a18(118) = a(64): a18(119) = a(65): a18(120) = a(66):
a18(121) = a(67): a18(122) = a(68): a18(123) = a(69): a18(124) = a(70):
a18(129) = a(71): a18(130) = a(72): a18(131) = a(73): a18(132) = a(74): a18(133) = a(75):
a18(134) = a(76): a18(135) = a(77): a18(136) = a(78): a18(137) = a(79): a18(138) = a(80):
a18(139) = a(81): a18(140) = a(82): a18(141) = a(83): a18(142) = a(84):
a18(147) = a(85): a18(148) = a(86): a18(149) = a(87): a18(150) = a(88): a18(151) = a(89):
a18(152) = a(90): a18(153) = a(91): a18(154) = a(92): a18(155) = a(93): a18(156) = a(94):
a18(157) = a(95): a18(158) = a(96): a18(159) = a(97): a18(160) = a(98):
a18(165) = a(99): a18(166) = a(100): a18(167) = a(101): a18(168) = a(102): a18(169) = a(103):
a18(170) = a(104): a18(171) = a(105): a18(172) = a(106): a18(173) = a(107): a18(174) = a(108):
a18(175) = a(109): a18(176) = a(110): a18(177) = a(111): a18(178) = a(112):
a18(183) = a(113): a18(184) = a(114): a18(185) = a(115): a18(186) = a(116): a18(187) = a(117):
a18(188) = a(118): a18(189) = a(119): a18(190) = a(120): a18(191) = a(121): a18(192) = a(122):
a18(193) = a(123): a18(194) = a(124): a18(195) = a(125): a18(196) = a(126):
a18(201) = a(127): a18(202) = a(128): a18(203) = a(129): a18(204) = a(130): a18(205) = a(131):
a18(206) = a(132): a18(207) = a(133): a18(208) = a(134): a18(209) = a(135): a18(210) = a(136):
a18(211) = a(137): a18(212) = a(138): a18(213) = a(139): a18(214) = a(140):
a18(219) = a(141): a18(220) = a(142): a18(221) = a(143): a18(222) = a(144): a18(223) = a(145):
a18(224) = a(146): a18(225) = a(147): a18(226) = a(148): a18(227) = a(149): a18(228) = a(150):
a18(229) = a(151): a18(230) = a(152): a18(231) = a(153): a18(232) = a(154):
a18(237) = a(155): a18(238) = a(156): a18(239) = a(157): a18(240) = a(158): a18(241) = a(159):
a18(242) = a(160): a18(243) = a(161): a18(244) = a(162): a18(245) = a(163): a18(246) = a(164):
a18(247) = a(165): a18(248) = a(166): a18(249) = a(167): a18(250) = a(168):
a18(255) = a(169): a18(256) = a(170): a18(257) = a(171): a18(258) = a(172): a18(259) = a(173):
a18(260) = a(174): a18(261) = a(175): a18(262) = a(176): a18(263) = a(177): a18(264) = a(178):
a18(265) = a(179): a18(266) = a(180): a18(267) = a(181): a18(268) = a(182):
a18(273) = a(183): a18(274) = a(184): a18(275) = a(185): a18(276) = a(186): a18(277) = a(187):
a18(278) = a(188): a18(279) = a(189): a18(280) = a(190): a18(281) = a(191): a18(282) = a(192):
a18(283) = a(193): a18(284) = a(194): a18(285) = a(195): a18(286) = a(196):
Return
' Remove used numbers a() from available numbers b1()
900 For i1 = 1 To n32
b1(a(i1)) = 0
Next i1
Return
' Double Check Identical Numbers a18()
800 fl1 = 1
For i1 = 1 To 324
a20 = a18(i1): If a20 = 0 Then GoTo 810
For i2 = (1 + i1) To 324
If a20 = a18(i2) Then fl1 = 0: Return
Next i2
810 Next i1
Return
' Print results (squares)
650 n5 = n5 + 1
If n5 = 2 Then
n5 = 1: k1 = k1 + 19: k2 = 1
Else
If n9 > 1 Then k2 = k2 + 19
End If
Cells(k1, k2 + 1).Select
Cells(k1, k2 + 1).Font.Color = -4165632
Cells(k1, k2 + 1).Value = CStr(s18)
i3 = 0
For i1 = 1 To 18
For i2 = 1 To 18
i3 = i3 + 1
Cells(k1 + i1, k2 + i2).Value = a18(i3)
Next i2
Next i1
Return
End Sub