' Generates Pan Magic Squares (Morris) of order 12, magic sum 870, Franklin Bent Diagonals
' Tested with Office 2007 under Windows 7
Sub MgcSqr12b()
Dim a(144), b(144), c(144)
y = MsgBox("Locked", vbCritical, "Routine MgcSqr12b")
End
n2 = 0: n9 = 0
m1 = 1: m2 = 144: s1 = 870
' Generate data
Sheets("Klad1").Select
t1 = Timer
For j144 = 4 To 4 'a(144)
If b(j144) = 0 Then b(j144) = j144: c(144) = j144 Else GoTo 1440
a(144) = j144
For j143 = 117 To 117 'a(143)
If b(j143) = 0 Then b(j143) = j143: c(143) = j143 Else GoTo 1430
a(143) = j143
For j142 = 124 To 124 'a(142)
If b(j142) = 0 Then b(j142) = j142: c(142) = j142 Else GoTo 1420
a(142) = j142
jj = 142
a(141) = 290 - a(142) - a(143) - a(144)
j = 141: GoSub 3000: If fl1 = 1 Then GoTo 1420
For j140 = 88 To 88 'a(140)
If b(j140) = 0 Then b(j140) = j140: c(140) = j140 Else GoTo 1400
a(140) = j140
For j139 = 69 To 69 'a(139)
If b(j139) = 0 Then b(j139) = j139: c(139) = j139 Else GoTo 1390
a(139) = j139
For j138 = 76 To 76 'a(138)
If b(j138) = 0 Then b(j138) = j138: c(138) = j138 Else GoTo 1380
a(138) = j138
jj = 138
a(137) = 290 - a(138) - a(139) - a(140)
j = 137: GoSub 3000: If fl1 = 1 Then GoTo 1380
For j136 = 100 To 100 'a(136)
If b(j136) = 0 Then b(j136) = j136: c(136) = j136 Else GoTo 1360
a(136) = j136
For j135 = m1 To m2 'a(135)
If b(j135) = 0 Then b(j135) = j135: c(135) = j135 Else GoTo 1350
a(135) = j135
jj = 135
a(134) = 145 - a(136) - a(138) - a(139) + a(142) + a(144)
j = 134: GoSub 3000: If fl1 = 1 Then GoTo 1350
a(133) = 145 - a(135) + a(138) + a(139) - a(142) - a(144)
j = 133: GoSub 3000: If fl1 = 1 Then GoTo 1350
For j132 = m1 To m2 'a(132)
If b(j132) = 0 Then b(j132) = j132: c(132) = j132 Else GoTo 1320
a(132) = j132
jj = 132
a(131) = 290 - a(132) - a(143) - a(144): j = 131: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(130) = a(132) - a(142) + a(144): j = 130: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(129) = -a(132) + a(142) + a(143): j = 129: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(128) = a(132) - a(140) + a(144): j = 128: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(127) = 290 - a(132) - a(139) - a(144): j = 127: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(126) = a(132) - a(138) + a(144): j = 126: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(125) = -a(132) + a(138) + a(139) + a(140) - a(144): j = 125: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(124) = a(132) - a(136) + a(144): j = 124: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(123) = 290 - a(132) - a(135) - a(144): j = 123: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(122) = -145 + a(132) + a(136) + a(138) + a(139) - a(142): j = 122: GoSub 3000: If fl1 = 1 Then GoTo 1320
a(121) = 145 - a(132) + a(135) - a(138) - a(139) + a(142): j = 121: GoSub 3000: If fl1 = 1 Then GoTo 1320
For j120 = m1 To m2 'a(120)
If b(j120) = 0 Then b(j120) = j120: c(120) = j120 Else GoTo 1200
a(120) = j120
jj = 120
a(119) = -a(120) + a(143) + a(144): j = 119: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(118) = a(120) + a(142) - a(144): j = 118: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(117) = 290 - a(120) - a(142) - a(143): j = 117: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(116) = a(120) + a(140) - a(144): j = 116: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(115) = -a(120) + a(139) + a(144): j = 115: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(114) = a(120) + a(138) - a(144): j = 114: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(113) = 290 - a(120) - a(138) - a(139) - a(140) + a(144): j = 113: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(112) = a(120) + a(136) - a(144): j = 112: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(111) = -a(120) + a(135) + a(144): j = 111: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(110) = 145 + a(120) - a(136) - a(138) - a(139) + a(142): j = 110: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(109) = 145 - a(120) - a(135) + a(138) + a(139) - a(142): j = 109: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(108) = 290 - a(120) - a(132) - a(144): j = 108: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(107) = a(120) + a(132) - a(143): j = 107: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(106) = 290 - a(120) - a(132) - a(142): j = 106: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(105) = -290 + a(120) + a(132) + a(142) + a(143) + a(144): j = 105: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(104) = 290 - a(120) - a(132) - a(140): j = 104: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(103) = a(120) + a(132) - a(139): j = 103: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(102) = 290 - a(120) - a(132) - a(138): j = 102: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(101) = -290 + a(120) + a(132) + a(138) + a(139) + a(140): j = 101: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(100) = 290 - a(120) - a(132) - a(136): j = 100: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(99) = a(120) + a(132) - a(135): j = 99: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(98) = 145 - a(120) - a(132) + a(136) + a(138) + a(139) - a(142) - a(144)
j = 98: GoSub 3000: If fl1 = 1 Then GoTo 1200
a(97) = -145 + a(120) + a(132) + a(135) - a(138) - a(139) + a(142) + a(144)
j = 97: GoSub 3000: If fl1 = 1 Then GoTo 1200
For j96 = m1 To m2 'a(96)
If b(j96) = 0 Then b(j96) = j96: c(96) = j96 Else GoTo 960
a(96) = j96
jj = 96
a(95) = -a(96) + a(143) + a(144): j = 95: GoSub 3000: If fl1 = 1 Then GoTo 960
a(94) = a(96) + a(142) - a(144): j = 94: GoSub 3000: If fl1 = 1 Then GoTo 960
a(93) = 290 - a(96) - a(142) - a(143): j = 93: GoSub 3000: If fl1 = 1 Then GoTo 960
a(92) = a(96) + a(140) - a(144): j = 92: GoSub 3000: If fl1 = 1 Then GoTo 960
a(91) = -a(96) + a(139) + a(144): j = 91: GoSub 3000: If fl1 = 1 Then GoTo 960
a(90) = a(96) + a(138) - a(144): j = 90: GoSub 3000: If fl1 = 1 Then GoTo 960
a(89) = 290 - a(96) - a(138) - a(139) - a(140) + a(144): j = 89: GoSub 3000: If fl1 = 1 Then GoTo 960
a(88) = a(96) + a(136) - a(144): j = 88: GoSub 3000: If fl1 = 1 Then GoTo 960
a(87) = -a(96) + a(135) + a(144): j = 87: GoSub 3000: If fl1 = 1 Then GoTo 960
a(86) = 145 + a(96) - a(136) - a(138) - a(139) + a(142): j = 86: GoSub 3000: If fl1 = 1 Then GoTo 960
a(85) = 145 - a(96) - a(135) + a(138) + a(139) - a(142): j = 85: GoSub 3000: If fl1 = 1 Then GoTo 960
a(84) = -145 + a(96) + 2 * a(120) - a(139) + a(140) + 2 * a(142) - 2 * a(144)
j = 84: GoSub 3000: If fl1 = 1 Then GoTo 960
a(83) = 435 - a(96) - 2 * a(120) + a(139) - a(140) - 2 * a(142) - a(143) + a(144)
j = 83: GoSub 3000: If fl1 = 1 Then GoTo 960
a(82) = -145 + a(96) + 2 * a(120) - a(139) + a(140) + a(142) - a(144)
j = 82: GoSub 3000: If fl1 = 1 Then GoTo 960
a(81) = 145 - a(96) - 2 * a(120) + a(139) - a(140) - a(142) + a(143) + 2 * a(144)
j = 81: GoSub 3000: If fl1 = 1 Then GoTo 960
a(80) = -145 + a(96) + 2 * a(120) - a(139) + 2 * a(142) - a(144)
j = 80: GoSub 3000: If fl1 = 1 Then GoTo 960
a(79) = 435 - a(96) - 2 * a(120) - a(140) - 2 * a(142) + a(144)
j = 79: GoSub 3000: If fl1 = 1 Then GoTo 960
a(78) = -145 + a(96) + 2 * a(120) - a(138) - a(139) + a(140) + 2 * a(142) - a(144)
j = 78: GoSub 3000: If fl1 = 1 Then GoTo 960
a(77) = 145 - a(96) - 2 * a(120) + a(138) + 2 * a(139) - 2 * a(142) + a(144)
j = 77: GoSub 3000: If fl1 = 1 Then GoTo 960
a(76) = -145 + a(96) + 2 * a(120) - a(136) - a(139) + a(140) + 2 * a(142) - a(144)
j = 76: GoSub 3000: If fl1 = 1 Then GoTo 960
a(75) = 435 - a(96) - 2 * a(120) - a(135) + a(139) - a(140) - 2 * a(142) + a(144)
j = 75: GoSub 3000: If fl1 = 1 Then GoTo 960
a(74) = -290 + a(96) + 2 * a(120) + a(136) + a(138) + a(140) + a(142) - 2 * a(144)
j = 74: GoSub 3000: If fl1 = 1 Then GoTo 960
a(73) = 290 - a(96) - 2 * a(120) + a(135) - a(138) - a(140) - a(142) + 2 * a(144)
j = 73: GoSub 3000: If fl1 = 1 Then GoTo 960
For j72 = m1 To m2 'a(72)
If b(j72) = 0 Then b(j72) = j72: c(72) = j72 Else GoTo 720
a(72) = j72
jj = 72
a(71) = -a(72) + a(143) + a(144): j = 71: GoSub 3000: If fl1 = 1 Then GoTo 720
a(70) = a(72) + a(142) - a(144): j = 70: GoSub 3000: If fl1 = 1 Then GoTo 720
a(69) = 290 - a(72) - a(142) - a(143): j = 69: GoSub 3000: If fl1 = 1 Then GoTo 720
a(68) = a(72) + a(140) - a(144): j = 68: GoSub 3000: If fl1 = 1 Then GoTo 720
a(67) = -a(72) + a(139) + a(144): j = 67: GoSub 3000: If fl1 = 1 Then GoTo 720
a(66) = a(72) + a(138) - a(144): j = 66: GoSub 3000: If fl1 = 1 Then GoTo 720
a(65) = 290 - a(72) - a(138) - a(139) - a(140) + a(144): j = 65: GoSub 3000: If fl1 = 1 Then GoTo 720
a(64) = a(72) + a(136) - a(144): j = 64: GoSub 3000: If fl1 = 1 Then GoTo 720
a(63) = -a(72) + a(135) + a(144): j = 63: GoSub 3000: If fl1 = 1 Then GoTo 720
a(62) = 145 + a(72) - a(136) - a(138) - a(139) + a(142): j = 62: GoSub 3000: If fl1 = 1 Then GoTo 720
a(61) = 145 - a(72) - a(135) + a(138) + a(139) - a(142): j = 61: GoSub 3000: If fl1 = 1 Then GoTo 720
a(60) = 435 - a(72) - 2 * a(96) - 2 * a(120) + a(139) - a(140) - 2 * a(142) + 2 * a(144)
j = 60: GoSub 3000: If fl1 = 1 Then GoTo 720
a(59) = -145 + a(72) + 2 * a(96) + 2 * a(120) - a(139) + a(140) + 2 * a(142) - a(143) - 3 * a(144)
j = 59: GoSub 3000: If fl1 = 1 Then GoTo 720
a(58) = 435 - a(72) - 2 * a(96) - 2 * a(120) + a(139) - a(140) - 3 * a(142) + 3 * a(144)
j = 58: GoSub 3000: If fl1 = 1 Then GoTo 720
a(57) = -435 + a(72) + 2 * a(96) + 2 * a(120) - a(139) + a(140) + 3 * a(142) + a(143) - 2 * a(144)
j = 57: GoSub 3000: If fl1 = 1 Then GoTo 720
a(56) = 435 - a(72) - 2 * a(96) - 2 * a(120) + a(139) - 2 * a(140) - 2 * a(142) + 3 * a(144)
j = 56: GoSub 3000: If fl1 = 1 Then GoTo 720
a(55) = -145 + a(72) + 2 * a(96) + 2 * a(120) - 2 * a(139) + a(140) + 2 * a(142) - 3 * a(144)
j = 55: GoSub 3000: If fl1 = 1 Then GoTo 720
a(54) = 435 - a(72) - 2 * a(96) - 2 * a(120) - a(138) + a(139) - a(140) - 2 * a(142) + 3 * a(144)
j = 54: GoSub 3000: If fl1 = 1 Then GoTo 720
a(53) = -435 + a(72) + 2 * a(96) + 2 * a(120) + a(138) + 2 * a(140) + 2 * a(142) - 3 * a(144)
j = 53: GoSub 3000: If fl1 = 1 Then GoTo 720
a(52) = 435 - a(72) - 2 * a(96) - 2 * a(120) - a(136) + a(139) - a(140) - 2 * a(142) + 3 * a(144)
j = 52: GoSub 3000: If fl1 = 1 Then GoTo 720
a(51) = -145 + a(72) + 2 * a(96) + 2 * a(120) - a(135) - a(139) + a(140) + 2 * a(142) - 3 * a(144)
j = 51: GoSub 3000: If fl1 = 1 Then GoTo 720
a(50) = 290 - a(72) - 2 * a(96) - 2 * a(120) + a(136) + a(138) + 2 * a(139) - a(140) - 3 * a(142) + 2 * a(144)
j = 50: GoSub 3000: If fl1 = 1 Then GoTo 720
a(49) = -290 + a(72) + 2 * a(96) + 2 * a(120) + a(135) - a(138) - 2 * a(139) + a(140) + 3 * a(142) - 2 * a(144)
j = 49: GoSub 3000: If fl1 = 1 Then GoTo 720
For j48 = m1 To m2 'a(48)
If b(j48) = 0 Then b(j48) = j48: c(48) = j48 Else GoTo 480
a(48) = j48
jj = 48
a(47) = -a(48) + a(143) + a(144): j = 47: GoSub 3000: If fl1 = 1 Then GoTo 480
a(46) = a(48) + a(142) - a(144): j = 46: GoSub 3000: If fl1 = 1 Then GoTo 480
a(45) = 290 - a(48) - a(142) - a(143): j = 45: GoSub 3000: If fl1 = 1 Then GoTo 480
a(44) = a(48) + a(140) - a(144): j = 44: GoSub 3000: If fl1 = 1 Then GoTo 480
a(43) = -a(48) + a(139) + a(144): j = 43: GoSub 3000: If fl1 = 1 Then GoTo 480
a(42) = a(48) + a(138) - a(144): j = 42: GoSub 3000: If fl1 = 1 Then GoTo 480
a(41) = 290 - a(48) - a(138) - a(139) - a(140) + a(144): j = 41: GoSub 3000: If fl1 = 1 Then GoTo 480
a(40) = a(48) + a(136) - a(144): j = 40: GoSub 3000: If fl1 = 1 Then GoTo 480
a(39) = -a(48) + a(135) + a(144): j = 39: GoSub 3000: If fl1 = 1 Then GoTo 480
a(38) = 145 + a(48) - a(136) - a(138) - a(139) + a(142): j = 38: GoSub 3000: If fl1 = 1 Then GoTo 480
a(37) = 145 - a(48) - a(135) + a(138) + a(139) - a(142): j = 37: GoSub 3000: If fl1 = 1 Then GoTo 480
For j36 = m1 To m2 'a(36)
If b(j36) = 0 Then b(j36) = j36: c(36) = j36 Else GoTo 360
a(36) = j36
jj = 36
a(35) = 290 - a(36) - a(143) - a(144): j = 35: GoSub 3000: If fl1 = 1 Then GoTo 360
a(34) = a(36) - a(142) + a(144): j = 34: GoSub 3000: If fl1 = 1 Then GoTo 360
a(33) = -a(36) + a(142) + a(143): j = 33: GoSub 3000: If fl1 = 1 Then GoTo 360
a(32) = a(36) - a(140) + a(144): j = 32: GoSub 3000: If fl1 = 1 Then GoTo 360
a(31) = 290 - a(36) - a(139) - a(144): j = 31: GoSub 3000: If fl1 = 1 Then GoTo 360
a(30) = a(36) - a(138) + a(144): j = 30: GoSub 3000: If fl1 = 1 Then GoTo 360
a(29) = -a(36) + a(138) + a(139) + a(140) - a(144): j = 29: GoSub 3000: If fl1 = 1 Then GoTo 360
a(28) = a(36) - a(136) + a(144): j = 28: GoSub 3000: If fl1 = 1 Then GoTo 360
a(27) = 290 - a(36) - a(135) - a(144): j = 27: GoSub 3000: If fl1 = 1 Then GoTo 360
a(26) = -145 + a(36) + a(136) + a(138) + a(139) - a(142): j = 26: GoSub 3000: If fl1 = 1 Then GoTo 360
a(25) = 145 - a(36) + a(135) - a(138) - a(139) + a(142): j = 25: GoSub 3000: If fl1 = 1 Then GoTo 360
a(24) = 290 - a(48) - a(72) - a(96) - a(120) + a(139) - a(140) - 2 * a(142) + 3 * a(144)
j = 24: GoSub 3000: If fl1 = 1 Then GoTo 360
a(23) = -290 + a(48) + a(72) + a(96) + a(120) - a(139) + a(140) + 2 * a(142) + a(143) - 2 * a(144)
j = 23: GoSub 3000: If fl1 = 1 Then GoTo 360
a(22) = 290 - a(48) - a(72) - a(96) - a(120) + a(139) - a(140) - a(142) + 2 * a(144)
j = 22: GoSub 3000: If fl1 = 1 Then GoTo 360
a(21) = a(48) + a(72) + a(96) + a(120) - a(139) + a(140) + a(142) - a(143) - 3 * a(144)
j = 21: GoSub 3000: If fl1 = 1 Then GoTo 360
a(20) = 290 - a(48) - a(72) - a(96) - a(120) + a(139) - 2 * a(142) + 2 * a(144)
j = 20: GoSub 3000: If fl1 = 1 Then GoTo 360
a(19) = -290 + a(48) + a(72) + a(96) + a(120) + a(140) + 2 * a(142) - 2 * a(144)
j = 19: GoSub 3000: If fl1 = 1 Then GoTo 360
a(18) = 290 - a(48) - a(72) - a(96) - a(120) + a(138) + a(139) - a(140) - 2 * a(142) + 2 * a(144)
j = 18: GoSub 3000: If fl1 = 1 Then GoTo 360
a(17) = a(48) + a(72) + a(96) + a(120) - a(138) - 2 * a(139) + 2 * a(142) - 2 * a(144)
j = 17: GoSub 3000: If fl1 = 1 Then GoTo 360
a(16) = 290 - a(48) - a(72) - a(96) - a(120) + a(136) + a(139) - a(140) - 2 * a(142) + 2 * a(144)
j = 16: GoSub 3000: If fl1 = 1 Then GoTo 360
a(15) = -290 + a(48) + a(72) + a(96) + a(120) + a(135) - a(139) + a(140) + 2 * a(142) - 2 * a(144)
j = 15: GoSub 3000: If fl1 = 1 Then GoTo 360
a(14) = 435 - a(48) - a(72) - a(96) - a(120) - a(136) - a(138) - a(140) - a(142) + 3 * a(144)
j = 14: GoSub 3000: If fl1 = 1 Then GoTo 360
a(13) = -145 + a(48) + a(72) + a(96) + a(120) - a(135) + a(138) + a(140) + a(142) - 3 * a(144)
j = 13: GoSub 3000: If fl1 = 1 Then GoTo 360
a(12) = -a(36) + a(72) + a(96) + a(120) - a(139) + a(140) + 2 * a(142) - 3 * a(144)
j = 12: GoSub 3000: If fl1 = 1 Then GoTo 360
a(11) = 290 + a(36) - a(72) - a(96) - a(120) + a(139) - a(140) - 2 * a(142) - a(143) + 2 * a(144)
j = 11: GoSub 3000: If fl1 = 1 Then GoTo 360
a(10) = -a(36) + a(72) + a(96) + a(120) - a(139) + a(140) + a(142) - 2 * a(144)
j = 10: GoSub 3000: If fl1 = 1 Then GoTo 360
a(9) = a(36) - a(72) - a(96) - a(120) + a(139) - a(140) - a(142) + a(143) + 3 * a(144)
j = 9: GoSub 3000: If fl1 = 1 Then GoTo 360
a(8) = -a(36) + a(72) + a(96) + a(120) - a(139) + 2 * a(142) - 2 * a(144)
j = 8: GoSub 3000: If fl1 = 1 Then GoTo 360
a(7) = 290 + a(36) - a(72) - a(96) - a(120) - a(140) - 2 * a(142) + 2 * a(144)
j = 7: GoSub 3000: If fl1 = 1 Then GoTo 360
a(6) = -a(36) + a(72) + a(96) + a(120) - a(138) - a(139) + a(140) + 2 * a(142) - 2 * a(144)
j = 6: GoSub 3000: If fl1 = 1 Then GoTo 360
a(5) = a(36) - a(72) - a(96) - a(120) + a(138) + 2 * a(139) - 2 * a(142) + 2 * a(144)
j = 5: GoSub 3000: If fl1 = 1 Then GoTo 360
a(4) = -a(36) + a(72) + a(96) + a(120) - a(136) - a(139) + a(140) + 2 * a(142) - 2 * a(144)
j = 4: GoSub 3000: If fl1 = 1 Then GoTo 360
a(3) = 290 + a(36) - a(72) - a(96) - a(120) - a(135) + a(139) - a(140) - 2 * a(142) + 2 * a(144)
j = 3: GoSub 3000: If fl1 = 1 Then GoTo 360
a(2) = -145 - a(36) + a(72) + a(96) + a(120) + a(136) + a(138) + a(140) + a(142) - 3 * a(144)
j = 2: GoSub 3000: If fl1 = 1 Then GoTo 360
a(1) = 145 + a(36) - a(72) - a(96) - a(120) + a(135) - a(138) - a(140) - a(142) + 3 * a(144)
j = 1: GoSub 3000: If fl1 = 1 Then GoTo 360
n9 = n9 + 1
GoSub 2650 'Print results (squares)
' GoSub 2645 'Print results (selected numbers
jj = 36: GoSub 3050 'Reset b() and c()
360 Next j36
jj = 48: GoSub 3050 'Reset b() and c()
480 Next j48
jj = 72: GoSub 3050 'Reset b() and c()
720 Next j72
jj = 96: GoSub 3050 'Reset b() and c()
960 Next j96
jj = 120: GoSub 3050 'Reset b() and c()
1200 Next j120
jj = 132: GoSub 3050 'Reset b() and c()
1320 Next j132
jj = 135: GoSub 3050 'Reset b() and c()
1350 Next j135
jj = 136: GoSub 3050 'Reset b() and c()
1360 Next j136
jj = 138: GoSub 3050 'Reset b() and c()
1380 Next j138
jj = 139: GoSub 3050 'Reset b() and c()
1390 Next j139
jj = 140: GoSub 3050 'Reset b() and c()
1400 Next j140
jj = 142: GoSub 3050 'Reset b() and c()
1420 Next j142
b(c(143)) = 0: c(143) = 0
1430 Next j143
b(c(144)) = 0: c(144) = 0
1440 Next j144
t2 = Timer
t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s1)
y = MsgBox(t10, 0, "Routine MgcSqr12b")
End
' Print results (selected numbers)
2645 For i1 = 1 To 144
Cells(n9, i1).Value = a(i1)
Next i1
Return
' Print results (squares)
2650 n2 = n2 + 1
If n2 = 3 Then
n2 = 1: k1 = k1 + 13: k2 = 0
Else
If n9 > 1 Then k2 = k2 + 13
End If
Cells(k1 + 1, k2 + 1).Select
i3 = 0
For i1 = 1 To 12
For i2 = 1 To 12
i3 = i3 + 1
Cells(k1 + i1, k2 + i2).Value = a(i3)
Next i2
Next i1
Return
' Exclude identical solutions and solutions out of range
3000 fl1 = 0
If a(j) <= 0 Or a(j) > 144 Then fl1 = 1: GoTo 3010
If b(a(j)) = 0 Then b(a(j)) = a(j): c(j) = a(j) Else fl1 = 1
3010 If fl1 = 1 Then 'Reset b() and c()
For i = j + 1 To jj
b(c(i)) = 0: c(i) = 0
Next i
End If
Return
' Reset b() and c() after completion loop
3050 For i = j To jj
b(c(i)) = 0: c(i) = 0
Next i
Return
End Sub