' Generates Bordered Magic Cubes of order 6 (Natural Numbers)
' Tested with Office 2007 under Windows 7
Sub MgcCube6i()
Dim a1(216), a(72), b1(216), b(216), c(72), c6(216)
Dim a2(72), c2(72) 'Back Square
y = MsgBox("Locked", vbCritical, "Routine MgcCube6i")
End
n2 = 0: n9 = 0: k1 = 1: k2 = 1
ShtNm1 = "AntSym6": ShtNm2 = "Pairs6"
Sheets("Klad1").Select
t1 = Timer
For j100 = 2 To 24 ' *** Solutions found for 2, 4, 5, 14 ... 17 ***
' Start reading data from ShtNm1
Rcrd1a = Sheets(ShtNm1).Cells(j100, 38).Value
s6 = Sheets(ShtNm1).Cells(j100, 37).Value
GoSub 4100 'Difine Border Integers
' Read Anti Symmetric Square
For i1 = 1 To 36
a(i1) = Sheets(ShtNm1).Cells(j100, i1).Value
Next i1
GoSub 750 'Fill Top and Bottom c6()
' Remove used numbers and complements from available numbers
For i1 = 1 To 36
b1(c6(i1)) = 0: b1(c6(180 + i1)) = 0
Next i1
' Store 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
' Define Left Square
Erase a 'Clear Scratch Area a()
For i1 = 1 To 6 'Define Top and Bottom Line
a(i1) = c6(1 + (i1 - 1) * 6): a(i1 + 30) = c6(181 + (i1 - 1) * 6)
Next i1
For j29 = m1 To m2 'a(29)
If b(a1(j29)) = 0 Then b(a1(j29)) = a1(j29): c(29) = a1(j29) Else GoTo 290
a(29) = a1(j29)
a(65) = PR3 - a(29): If b(a(65)) = 0 Then b(a(65)) = a(65): c(65) = a(65) Else GoTo 650
For j22 = m1 To m2 'a(22)
If b(a1(j22)) = 0 Then b(a1(j22)) = a1(j22): c(22) = a1(j22) Else GoTo 220
a(22) = a1(j22)
a(58) = PR3 - a(22): If b(a(58)) = 0 Then b(a(58)) = a(58): c(58) = a(58) Else GoTo 580
For j15 = m1 To m2 'a(15)
If b(a1(j15)) = 0 Then b(a1(j15)) = a1(j15): c(15) = a1(j15) Else GoTo 150
a(15) = a1(j15)
a(51) = PR3 - a(15): If b(a(51)) = 0 Then b(a(51)) = a(51): c(51) = a(51) Else GoTo 510
a(8) = s6 - a(15) - a(22) - a(29) - a(1) - a(36)
If a(8) < a1(m1) Or a(8) > a1(m2) Then GoTo 80
If b1(a(8)) = 0 Then GoTo 80
If b(a(8)) = 0 Then b(a(8)) = a(8): c(8) = a(8) Else GoTo 80
a(44) = PR3 - a(8): If b(a(44)) = 0 Then b(a(44)) = a(44): c(44) = a(44) Else GoTo 440
For j23 = m1 To m2 'a(23)
If b(a1(j23)) = 0 Then b(a1(j23)) = a1(j23): c(23) = a1(j23) Else GoTo 230
a(23) = a1(j23)
a(59) = PR3 - a(23): If b(a(59)) = 0 Then b(a(59)) = a(59): c(59) = a(59) Else GoTo 590
For j17 = m1 To m2 'a(17)
If b(a1(j17)) = 0 Then b(a1(j17)) = a1(j17): c(17) = a1(j17) Else GoTo 170
a(17) = a1(j17)
a(53) = PR3 - a(17): If b(a(53)) = 0 Then b(a(53)) = a(53): c(53) = a(53) Else GoTo 530
a(11) = s6 - a(17) - a(23) - a(29) - a(5) - a(35)
If a(11) < a1(m1) Or a(11) > a1(m2) Then GoTo 110
If b1(a(11)) = 0 Then GoTo 110
If b(a(11)) = 0 Then b(a(11)) = a(11): c(11) = a(11) Else GoTo 110
a(47) = PR3 - a(11): If b(a(47)) = 0 Then b(a(47)) = a(47): c(47) = a(47) Else GoTo 470
For j26 = m1 To m2 'a(26)
If b(a1(j26)) = 0 Then b(a1(j26)) = a1(j26): c(26) = a1(j26) Else GoTo 260
a(26) = a1(j26)
a(62) = PR3 - a(26): If b(a(62)) = 0 Then b(a(62)) = a(62): c(62) = a(62) Else GoTo 620
For j21 = m1 To m2 'a(21)
If b(a1(j21)) = 0 Then b(a1(j21)) = a1(j21): c(21) = a1(j21) Else GoTo 210
a(21) = a1(j21)
a(57) = PR3 - a(21): If b(a(57)) = 0 Then b(a(57)) = a(57): c(57) = a(57) Else GoTo 570
a(16) = s6 - a(21) - a(26) - a(11) - a(6) - a(31)
If a(16) < a1(m1) Or a(16) > a1(m2) Then GoTo 160
If b1(a(16)) = 0 Then GoTo 160
If b(a(16)) = 0 Then b(a(16)) = a(16): c(16) = a(16) Else GoTo 160
a(52) = PR3 - a(16): If b(a(52)) = 0 Then b(a(52)) = a(52): c(52) = a(52) Else GoTo 520
For j20 = m1 To m2 'a(20)
If b(a1(j20)) = 0 Then b(a1(j20)) = a1(j20): c(20) = a1(j20) Else GoTo 200
a(20) = a1(j20)
a(56) = PR3 - a(20): If b(a(56)) = 0 Then b(a(56)) = a(56): c(56) = a(56) Else GoTo 560
a(14) = s6 - a(20) - a(26) - a(8) - a(2) - a(32)
If a(14) < a1(m1) Or a(14) > a1(m2) Then GoTo 140
If b1(a(14)) = 0 Then GoTo 140
If b(a(14)) = 0 Then b(a(14)) = a(14): c(14) = a(14) Else GoTo 140
a(50) = PR3 - a(14): If b(a(50)) = 0 Then b(a(50)) = a(50): c(50) = a(50) Else GoTo 500
For j28 = m1 To m2 'a(28)
If b(a1(j28)) = 0 Then b(a1(j28)) = a1(j28): c(28) = a1(j28) Else GoTo 280
a(28) = a1(j28)
a(64) = PR3 - a(28): If b(a(64)) = 0 Then b(a(64)) = a(64): c(64) = a(64) Else GoTo 640
a(10) = s6 - a(28) - a(16) - a(22) - a(4) - a(34)
If a(10) < a1(m1) Or a(10) > a1(m2) Then GoTo 100
If b1(a(10)) = 0 Then GoTo 100
If b(a(10)) = 0 Then b(a(10)) = a(10): c(10) = a(10) Else GoTo 100
a(46) = PR3 - a(10): If b(a(46)) = 0 Then b(a(46)) = a(46): c(46) = a(46) Else GoTo 460
For j27 = m1 To m2 'a(27)
If b(a1(j27)) = 0 Then b(a1(j27)) = a1(j27): c(27) = a1(j27) Else GoTo 270
a(27) = a1(j27)
a(63) = PR3 - a(27): If b(a(63)) = 0 Then b(a(63)) = a(63): c(63) = a(63) Else GoTo 630
a(9) = s6 - a(27) - a(21) - a(15) - a(3) - a(33)
If a(9) < a1(m1) Or a(9) > a1(m2) Then GoTo 90
If b1(a(9)) = 0 Then GoTo 90
If b(a(9)) = 0 Then b(a(9)) = a(9): c(9) = a(9) Else GoTo 90
a(45) = PR3 - a(9): If b(a(45)) = 0 Then b(a(45)) = a(45): c(45) = a(45) Else GoTo 450
For j30 = m1 To m2 'a(30)
If b(a1(j30)) = 0 Then b(a1(j30)) = a1(j30): c(30) = a1(j30) Else GoTo 300
a(30) = a1(j30)
a(66) = PR3 - a(30): If b(a(66)) = 0 Then b(a(66)) = a(66): c(66) = a(66) Else GoTo 660
a(25) = s6 - a(30) - a(27) - a(28) - a(26) - a(29)
If a(25) < a1(m1) Or a(25) > a1(m2) Then GoTo 250
If b1(a(25)) = 0 Then GoTo 250
If b(a(25)) = 0 Then b(a(25)) = a(25): c(25) = a(25) Else GoTo 250
a(61) = PR3 - a(25): If b(a(61)) = 0 Then b(a(61)) = a(61): c(61) = a(61) Else GoTo 610
For j24 = m1 To m2 'a(24)
If b(a1(j24)) = 0 Then b(a1(j24)) = a1(j24): c(24) = a1(j24) Else GoTo 240
a(24) = a1(j24)
a(60) = PR3 - a(24): If b(a(60)) = 0 Then b(a(60)) = a(60): c(60) = a(60) Else GoTo 600
a(19) = s6 - a(24) - a(20) - a(21) - a(23) - a(22)
If a(19) < a1(m1) Or a(19) > a1(m2) Then GoTo 190
If b1(a(19)) = 0 Then GoTo 190
If b(a(19)) = 0 Then b(a(19)) = a(19): c(19) = a(19) Else GoTo 190
a(55) = PR3 - a(19): If b(a(55)) = 0 Then b(a(55)) = a(55): c(55) = a(55) Else GoTo 550
For j18 = m1 To m2 'a(18)
If b(a1(j18)) = 0 Then b(a1(j18)) = a1(j18): c(18) = a1(j18) Else GoTo 180
a(18) = a1(j18)
a(54) = PR3 - a(18): If b(a(54)) = 0 Then b(a(54)) = a(54): c(54) = a(54) Else GoTo 540
a(13) = s6 - a(18) - a(14) - a(16) - a(17) - a(15)
If a(13) < a1(m1) Or a(13) > a1(m2) Then GoTo 130
If b1(a(13)) = 0 Then GoTo 130
If b(a(13)) = 0 Then b(a(13)) = a(13): c(13) = a(13) Else GoTo 130
a(49) = PR3 - a(13): If b(a(49)) = 0 Then b(a(49)) = a(49): c(49) = a(49) Else GoTo 490
a(12) = s6 - a(30) - a(18) - a(24) - a(6) - a(36)
If a(12) < a1(m1) Or a(12) > a1(m2) Then GoTo 120
If b1(a(12)) = 0 Then GoTo 120
If b(a(12)) = 0 Then b(a(12)) = a(12): c(12) = a(12) Else GoTo 120
a(48) = PR3 - a(12): If b(a(48)) = 0 Then b(a(48)) = a(48): c(48) = a(48) Else GoTo 480
a(7) = s6 - a(12) - a(9) - a(10) - a(11) - a(8)
If a(7) < a1(m1) Or a(7) > a1(m2) Then GoTo 70
If b1(a(7)) = 0 Then GoTo 70
If b(a(7)) = 0 Then b(a(7)) = a(7): c(7) = a(7) Else GoTo 70
a(43) = PR3 - a(7): If b(a(43)) = 0 Then b(a(43)) = a(43): c(43) = a(43) Else GoTo 430
GoSub 760 'Fill Left and Right Square c6()
GoSub 3000 'Determine Back Square (Magic)
If fl2 = 0 Then GoTo 5
GoSub 850 'Exclude solutions with identical numbers c6()
If fl1 = 0 Then GoTo 5
n9 = n9 + 1: GoSub 2750 'Print c6()
GoTo 1000
5
b(c(43)) = 0: c(43) = 0
430 b(c(7)) = 0: c(7) = 0
70 b(c(48)) = 0: c(48) = 0
480 b(c(12)) = 0: c(12) = 0
120 b(c(49)) = 0: c(49) = 0
490 b(c(13)) = 0: c(13) = 0
130 b(c(54)) = 0: c(54) = 0
540 b(c(18)) = 0: c(18) = 0
180 Next j18
b(c(55)) = 0: c(55) = 0
550 b(c(19)) = 0: c(19) = 0
190 b(c(60)) = 0: c(60) = 0
600 b(c(24)) = 0: c(24) = 0
240 Next j24
b(c(61)) = 0: c(61) = 0
610 b(c(25)) = 0: c(25) = 0
250 b(c(66)) = 0: c(66) = 0
660 b(c(30)) = 0: c(30) = 0
300 Next j30
b(c(45)) = 0: c(45) = 0
450 b(c(9)) = 0: c(9) = 0
90 b(c(63)) = 0: c(63) = 0
630 b(c(27)) = 0: c(27) = 0
270 Next j27
b(c(46)) = 0: c(46) = 0
460 b(c(10)) = 0: c(10) = 0
100 b(c(64)) = 0: c(64) = 0
640 b(c(28)) = 0: c(28) = 0
280 Next j28
b(c(50)) = 0: c(50) = 0
500 b(c(14)) = 0: c(14) = 0
140 b(c(56)) = 0: c(56) = 0
560 b(c(20)) = 0: c(20) = 0
200 Next j20
b(c(52)) = 0: c(52) = 0
520 b(c(16)) = 0: c(16) = 0
160 b(c(57)) = 0: c(57) = 0
570 b(c(21)) = 0: c(21) = 0
210 Next j21
b(c(62)) = 0: c(62) = 0
620 b(c(26)) = 0: c(26) = 0
260 Next j26
b(c(47)) = 0: c(47) = 0
470 b(c(11)) = 0: c(11) = 0
110 b(c(53)) = 0: c(53) = 0
530 b(c(17)) = 0: c(17) = 0
170 Next j17
b(c(59)) = 0: c(59) = 0
590 b(c(23)) = 0: c(23) = 0
230 Next j23
b(c(44)) = 0: c(44) = 0
440 b(c(8)) = 0: c(8) = 0
80 b(c(51)) = 0: c(51) = 0
510 b(c(15)) = 0: c(15) = 0
150 Next j15
b(c(58)) = 0: c(58) = 0
580 b(c(22)) = 0: c(22) = 0
220 Next j22
b(c(65)) = 0: c(65) = 0
650 b(c(29)) = 0: c(29) = 0
290 Next j29
1000 Erase b1, b, c: n6 = 0
Next j100
t2 = Timer
t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s6)
y = MsgBox(t10, 0, "Routine MgcCube6i")
End
' Determine Back Square and Complete Cube
3000 fl2 = 1
Erase a2, c2 'Clear Scratch Areas
a2(1) = c6(1): a2(2) = c6(2): a2(3) = c6(3): a2(4) = c6(4): a2(5) = c6(5): a2(6) = c6(6):
a2(7) = c6(37): a2(12) = c6(42):
a2(13) = c6(73): a2(18) = c6(78):
a2(19) = c6(109): a2(24) = c6(114):
a2(25) = c6(145): a2(30) = c6(150):
a2(31) = c6(181): a2(32) = c6(182): a2(33) = c6(183): a2(34) = c6(184): a2(35) = c6(185): a2(36) = c6(186):
For jj29 = m1 To m2 'a2(29)
If b(a1(jj29)) = 0 Then b(a1(jj29)) = a1(jj29): c2(29) = a1(jj29) Else GoTo 3290
a2(29) = a1(jj29)
a2(65) = PR3 - a2(29): If b(a2(65)) = 0 Then b(a2(65)) = a2(65): c2(65) = a2(65) Else GoTo 3650
For jj22 = m1 To m2 'a2(22)
If b(a1(jj22)) = 0 Then b(a1(jj22)) = a1(jj22): c2(22) = a1(jj22) Else GoTo 3220
a2(22) = a1(jj22)
a2(58) = PR3 - a2(22): If b(a2(58)) = 0 Then b(a2(58)) = a2(58): c2(58) = a2(58) Else GoTo 3580
For jj15 = m1 To m2 'a2(15)
If b(a1(jj15)) = 0 Then b(a1(jj15)) = a1(jj15): c2(15) = a1(jj15) Else GoTo 3150
a2(15) = a1(jj15)
a2(51) = PR3 - a2(15): If b(a2(51)) = 0 Then b(a2(51)) = a2(51): c2(51) = a2(51) Else GoTo 3510
a2(8) = s6 - a2(1) - a2(15) - a2(22) - a2(29) - a2(36)
If a2(8) < a1(m1) Or a2(8) > a1(m2) Then GoTo 3080
If b1(a2(8)) = 0 Then GoTo 3080
If b(a2(8)) = 0 Then b(a2(8)) = a2(8): c2(8) = a2(8) Else GoTo 3080
a2(44) = PR3 - a2(8): If b(a2(44)) = 0 Then b(a2(44)) = a2(44): c2(44) = a2(44) Else GoTo 3440
For jj26 = m1 To m2 'a2(26)
If b(a1(jj26)) = 0 Then b(a1(jj26)) = a1(jj26): c2(26) = a1(jj26) Else GoTo 3260
a2(26) = a1(jj26)
a2(62) = PR3 - a2(26): If b(a2(62)) = 0 Then b(a2(62)) = a2(62): c2(62) = a2(62) Else GoTo 3620
For jj21 = m1 To m2 'a2(21)
If b(a1(jj21)) = 0 Then b(a1(jj21)) = a1(jj21): c2(21) = a1(jj21) Else GoTo 3210
a2(21) = a1(jj21)
a2(57) = PR3 - a2(21): If b(a2(57)) = 0 Then b(a2(57)) = a2(57): c2(57) = a2(57) Else GoTo 3570
a2(16) = (2*s6-2*a2(21)-2*a2(15)-2*a2(22)-a2(1)-a2(3)-a2(4)-a2(6)+a2(7) +
+a2(12)+a2(25)+a2(30)-a2(31)-a2(33)-a2(34)-a2(36))/2
If a2(16) < a1(m1) Or a2(16) > a1(m2) Or CInt(a2(16)) <> a2(16) Then GoTo 3160
If b1(a2(16)) = 0 Then GoTo 3160
If b(a2(16)) = 0 Then b(a2(16)) = a2(16): c2(16) = a2(16) Else GoTo 3160
a2(52) = PR3 - a2(16): If b(a2(52)) = 0 Then b(a2(52)) = a2(52): c2(52) = a2(52) Else GoTo 3520
a2(11) = s6 - a2(6) - a2(16) - a2(21) - a2(26) - a2(31)
If a2(11) < a1(m1) Or a2(11) > a1(m2) Then GoTo 3110
If b1(a2(11)) = 0 Then GoTo 3110
If b(a2(11)) = 0 Then b(a2(11)) = a2(11): c2(11) = a2(11) Else GoTo 3110
a2(47) = PR3 - a2(11): If b(a2(47)) = 0 Then b(a2(47)) = a2(47): c2(47) = a2(47) Else GoTo 3470
For jj28 = m1 To m2 'a2(28)
If b(a1(jj28)) = 0 Then b(a1(jj28)) = a1(jj28): c2(28) = a1(jj28) Else GoTo 3280
a2(28) = a1(jj28)
a2(64) = PR3 - a2(28): If b(a2(64)) = 0 Then b(a2(64)) = a2(64): c2(64) = a2(64) Else GoTo 3640
a2(27) = s6 - a2(25) - a2(26) - a2(28) - a2(29) - a2(30)
If a2(27) < a1(m1) Or a2(27) > a1(m2) Then GoTo 3270
If b1(a2(27)) = 0 Then GoTo 3270
If b(a2(27)) = 0 Then b(a2(27)) = a2(27): c2(27) = a2(27) Else GoTo 3270
a2(63) = PR3 - a2(27): If b(a2(63)) = 0 Then b(a2(63)) = a2(63): c2(63) = a2(63) Else GoTo 3630
a2(10) = s6 - a2(16) - a2(22) - a2(28) - a2(4) - a2(34)
If a2(10) < a1(m1) Or a2(10) > a1(m2) Then GoTo 3100
If b1(a2(10)) = 0 Then GoTo 3100
If b(a2(10)) = 0 Then b(a2(10)) = a2(10): c2(10) = a2(10) Else GoTo 3100
a2(46) = PR3 - a2(10): If b(a2(46)) = 0 Then b(a2(46)) = a2(46): c2(46) = a2(46) Else GoTo 3460
a2(9) = s6 - a2(15) - a2(21) - a2(27) - a2(3) - a2(33)
If a2(9) < a1(m1) Or a2(9) > a1(m2) Then GoTo 3090
If b1(a2(9)) = 0 Then GoTo 3090
If b(a2(9)) = 0 Then b(a2(9)) = a2(9): c2(9) = a2(9) Else GoTo 3090
a2(45) = PR3 - a2(9): If b(a2(45)) = 0 Then b(a2(45)) = a2(45): c2(45) = a2(45) Else GoTo 3450
For jj23 = m1 To m2 'a2(23)
If b(a1(jj23)) = 0 Then b(a1(jj23)) = a1(jj23): c2(23) = a1(jj23) Else GoTo 3230
a2(23) = a1(jj23)
a2(59) = PR3 - a2(23): If b(a2(59)) = 0 Then b(a2(59)) = a2(59): c2(59) = a2(59) Else GoTo 3590
a2(20) = s6 - a2(21) - a2(22) - a2(23) - a2(19) - a2(24)
If a2(20) < a1(m1) Or a2(20) > a1(m2) Then GoTo 3200
If b1(a2(20)) = 0 Then GoTo 3200
If b(a2(20)) = 0 Then b(a2(20)) = a2(20): c2(20) = a2(20) Else GoTo 3200
a2(56) = PR3 - a2(20): If b(a2(56)) = 0 Then b(a2(56)) = a2(56): c2(56) = a2(56) Else GoTo 3560
a2(17) = s6 - a2(11) - a2(23) - a2(29) - a2(5) - a2(35)
If a2(17) < a1(m1) Or a2(17) > a1(m2) Then GoTo 3170
If b1(a2(17)) = 0 Then GoTo 3170
If b(a2(17)) = 0 Then b(a2(17)) = a2(17): c2(17) = a2(17) Else GoTo 3170
a2(53) = PR3 - a2(17): If b(a2(53)) = 0 Then b(a2(53)) = a2(53): c2(53) = a2(53) Else GoTo 3530
a2(14) = s6 - a2(15) - a2(16) - a2(17) - a2(13) - a2(18)
If a2(14) < a1(m1) Or a2(14) > a1(m2) Then GoTo 3140
If b1(a2(14)) = 0 Then GoTo 3140
If b(a2(14)) = 0 Then b(a2(14)) = a2(14): c2(14) = a2(14) Else GoTo 3140
a2(50) = PR3 - a2(14): If b(a2(50)) = 0 Then b(a2(50)) = a2(50): c2(50) = a2(50) Else GoTo 3500
GoSub 770 'Fill Back and Front Square c6()
GoSub 3600 'Reset Variables
Return
b(c2(50)) = 0: c2(50) = 0
3500 b(c2(14)) = 0: c2(14) = 0
3140 b(c2(53)) = 0: c2(53) = 0
3530 b(c2(17)) = 0: c2(17) = 0
3170 b(c2(56)) = 0: c2(56) = 0
3560 b(c2(20)) = 0: c2(20) = 0
3200 b(c2(59)) = 0: c2(59) = 0
3590 b(c2(23)) = 0: c2(23) = 0
3230 Next jj23
b(c2(45)) = 0: c2(45) = 0
3450 b(c2(9)) = 0: c2(9) = 0
3090 b(c2(46)) = 0: c2(46) = 0
3460 b(c2(10)) = 0: c2(10) = 0
3100 b(c2(63)) = 0: c2(63) = 0
3630 b(c2(27)) = 0: c2(27) = 0
3270 b(c2(64)) = 0: c2(64) = 0
3640 b(c2(28)) = 0: c2(28) = 0
3280 Next jj28
b(c2(47)) = 0: c2(47) = 0
3470 b(c2(11)) = 0: c2(11) = 0
3110 b(c2(52)) = 0: c2(52) = 0
3520 b(c2(16)) = 0: c2(16) = 0
3160
b(c2(57)) = 0: c2(57) = 0
3570 b(c2(21)) = 0: c2(21) = 0
3210 Next jj21
b(c2(62)) = 0: c2(62) = 0
3620 b(c2(26)) = 0: c2(26) = 0
3260 Next jj26
b(c2(44)) = 0: c2(44) = 0
3440 b(c2(8)) = 0: c2(8) = 0
3080 b(c2(51)) = 0: c2(51) = 0
3510 b(c2(15)) = 0: c2(15) = 0
3150 Next jj15
b(c2(58)) = 0: c2(58) = 0
3580 b(c2(22)) = 0: c2(22) = 0
3220 Next jj22
b(c2(65)) = 0: c2(65) = 0
3650 b(c2(29)) = 0: c2(29) = 0
3290 Next jj29
fl2 = 0 'Not Found
Return
' Reset variables
3600
b(c2(8)) = 0: c2(8) = 0: b(c2(9)) = 0: c2(9) = 0: b(c2(10)) = 0: c2(10) = 0: b(c2(11)) = 0: c2(11) = 0:
b(c2(14)) = 0: c2(14) = 0: b(c2(15)) = 0: c2(15) = 0: b(c2(16)) = 0: c2(16) = 0: b(c2(17)) = 0: c2(17) = 0:
b(c2(20)) = 0: c2(20) = 0: b(c2(21)) = 0: c2(21) = 0: b(c2(22)) = 0: c2(22) = 0: b(c2(23)) = 0: c2(23) = 0:
b(c2(26)) = 0: c2(26) = 0: b(c2(27)) = 0: c2(27) = 0: b(c2(28)) = 0: c2(28) = 0: b(c2(29)) = 0: c2(29) = 0:
b(c2(44)) = 0: c2(44) = 0: b(c2(45)) = 0: c2(45) = 0: b(c2(46)) = 0: c2(46) = 0: b(c2(47)) = 0: c2(47) = 0:
b(c2(50)) = 0: c2(50) = 0: b(c2(51)) = 0: c2(51) = 0: b(c2(52)) = 0: c2(52) = 0: b(c2(53)) = 0: c2(53) = 0:
b(c2(56)) = 0: c2(56) = 0: b(c2(57)) = 0: c2(57) = 0: b(c2(58)) = 0: c2(58) = 0: b(c2(59)) = 0: c2(59) = 0:
b(c2(62)) = 0: c2(62) = 0: b(c2(63)) = 0: c2(63) = 0: b(c2(64)) = 0: c2(64) = 0: b(c2(65)) = 0: c2(65) = 0:
Return
' Fill Top and Bottom c6()
750 For i1 = 1 To 36 'Top Square
c6(i1) = a(i1)
Next i1
' Bottom Square
c6(181) = PR3 - c6(36): c6(182) = PR3 - c6(32): c6(183) = PR3 - c6(33):
c6(184) = PR3 - c6(34): c6(185) = PR3 - c6(35): c6(186) = PR3 - c6(31):
c6(187) = PR3 - c6(12): c6(188) = PR3 - c6(8): c6(189) = PR3 - c6(9):
c6(190) = PR3 - c6(10): c6(191) = PR3 - c6(11): c6(192) = PR3 - c6(7):
c6(193) = PR3 - c6(18): c6(194) = PR3 - c6(14): c6(195) = PR3 - c6(15):
c6(196) = PR3 - c6(16): c6(197) = PR3 - c6(17): c6(198) = PR3 - c6(13):
c6(199) = PR3 - c6(24): c6(200) = PR3 - c6(20): c6(201) = PR3 - c6(21):
c6(202) = PR3 - c6(22): c6(203) = PR3 - c6(23): c6(204) = PR3 - c6(19):
c6(205) = PR3 - c6(30): c6(206) = PR3 - c6(26): c6(207) = PR3 - c6(27):
c6(208) = PR3 - c6(28): c6(209) = PR3 - c6(29): c6(210) = PR3 - c6(25):
c6(211) = PR3 - c6(6): c6(212) = PR3 - c6(2): c6(213) = PR3 - c6(3):
c6(214) = PR3 - c6(4): c6(215) = PR3 - c6(5): c6(216) = PR3 - c6(1):
Return
' Fill Left and Right Square
760
c6(37) = a(7): c6(43) = a(8): c6(49) = a(9): c6(55) = a(10): c6(61) = a(11): c6(67) = a(12):
c6(73) = a(13): c6(79) = a(14): c6(85) = a(15): c6(91) = a(16): c6(97) = a(17): c6(103) = a(18):
c6(109) = a(19): c6(115) = a(20): c6(121) = a(21): c6(127) = a(22): c6(133) = a(23): c6(139) = a(24):
c6(145) = a(25): c6(151) = a(26): c6(157) = a(27): c6(163) = a(28): c6(169) = a(29): c6(175) = a(30):
' Right Square
c6(156) = PR3 - c6(151): c6(162) = PR3 - c6(157): c6(168) = PR3 - c6(163): c6(174) = PR3 - c6(169):
c6(120) = PR3 - c6(115): c6(126) = PR3 - c6(121): c6(132) = PR3 - c6(127): c6(138) = PR3 - c6(133):
c6(84) = PR3 - c6(79): c6(90) = PR3 - c6(85): c6(96) = PR3 - c6(91): c6(102) = PR3 - c6(97):
c6(48) = PR3 - c6(43): c6(54) = PR3 - c6(49): c6(60) = PR3 - c6(55): c6(66) = PR3 - c6(61):
c6(150) = PR3 - c6(175): c6(180) = PR3 - c6(145): c6(114) = PR3 - c6(139): c6(144) = PR3 - c6(109):
c6(78) = PR3 - c6(103): c6(108) = PR3 - c6(73): c6(42) = PR3 - c6(67): c6(72) = PR3 - c6(37):
Return
' Fill Back and Front Square
770
c6(38) = a2(8): c6(39) = a2(9): c6(40) = a2(10): c6(41) = a2(11):
c6(74) = a2(14): c6(75) = a2(15): c6(76) = a2(16): c6(77) = a2(17):
c6(110) = a2(20): c6(111) = a2(21): c6(112) = a2(22): c6(113) = a2(23):
c6(146) = a2(26): c6(147) = a2(27): c6(148) = a2(28): c6(149) = a2(29):
' Front Square
c6(68) = PR3 - a2(8): c6(69) = PR3 - a2(9): c6(70) = PR3 - a2(10): c6(71) = PR3 - a2(11):
c6(104) = PR3 - a2(14): c6(105) = PR3 - a2(15): c6(106) = PR3 - a2(16): c6(107) = PR3 - a2(17):
c6(140) = PR3 - a2(20): c6(141) = PR3 - a2(21): c6(142) = PR3 - a2(22): c6(143) = PR3 - a2(23):
c6(176) = PR3 - a2(26): c6(177) = PR3 - a2(27): c6(178) = PR3 - a2(28): c6(179) = PR3 - a2(29):
Return
' Exclude solutions with identical numbers c6()
850 fl1 = 1
For j1 = 1 To 216
a20 = c6(j1): If a20 = 0 Then GoTo 855
For j2 = (1 + j1) To 216
If a20 = c6(j2) Then fl1 = 0: Return
Next j2
855 Next j1
Return
' Print Cubes (6 plane format)
2750 n2 = n2 + 1
If n2 = 5 Then
n2 = 1: k1 = k1 + 42: k2 = 1
Else
If n9 > 1 Then k2 = k2 + 7
End If
Cells(k1, k2 + 1).Select
Cells(k1, k2 + 1).Font.Color = -4165632
Cells(k1, k2 + 1).Value = j100 ''n9
For i0 = 1 To 6
i3 = (6 - i0) * 36
For i1 = 1 To 6
For i2 = 1 To 6
i3 = i3 + 1
Cells(k1 + i1 + (i0 - 1) * 7, k2 + i2).Value = c6(i3) 'Bordered Magic Cube
Next i2
Next i1
Next i0
Return
' Read Prime Numbers From Sheet ShtNm2
4100 PR3 = Sheets(ShtNm2).Cells(Rcrd1a, 1).Value 'Pair Sum
s6 = 3 * PR3 'MC6
nVar = Sheets(ShtNm2).Cells(Rcrd1a, 5).Value
m1 = 1: m2 = nVar
For i1 = m1 To m2
a1(i1) = Sheets(ShtNm2).Cells(Rcrd1a, i1 + 10).Value
Next i1
pMax = a1(m2)
Erase b1
For i1 = m1 To m2
b1(a1(i1)) = a1(i1)
Next i1
Return
End Sub