Vorige Pagina About the Author

' Generating Magic Squares of order 10, Medjig Solution (distinct integers)
' Bimagic Center Lines

' Tested with Office 2007 under Windows 7

Sub MgcSqr10a3()

Dim a(100), b1(25), c1(100), b(25, 4), c(25, 4), c10(10)

y = MsgBox("Locked", vbCritical, "Routine MgcSqr10a3")
End

n2 = 0: n3 = 0: n9 = 0: k1 = 1: k2 = 1

Sheets("Klad1").Select

t1 = Timer

For j110 = 2 To 2 ''89
Cells(k1, 1).Select: Cells(k1, 1).Value = j110

' 5 x 5 square for corresponding 10 x 10 Magic Squares

For i1 = 1 To 25
    b1(i1) = Sheets("Lines5").Cells(j110, i1).Value
Next i1

    t11 = Timer                                                     'Time Out

For j60 = 1 To 4                                                    'a(60)
If b(15, j60) = 0 Then b(15, j60) = j60: c(15, 4) = j60 Else GoTo 600
a(60) = j60 - 1

For j59 = 1 To 4                                                     'a(59)
If b(15, j59) = 0 Then b(15, j59) = j59: c(15, 3) = j59 Else GoTo 590
a(59) = j59 - 1

For j58 = 1 To 4                                                     'a(58)
If b(14, j58) = 0 Then b(14, j58) = j58: c(14, 4) = j58 Else GoTo 580
a(58) = j58 - 1

For j57 = 1 To 4                                                     'a(57)
If b(14, j57) = 0 Then b(14, j57) = j57: c(14, 3) = j57 Else GoTo 570
a(57) = j57 - 1

For j56 = 1 To 4                                                     'a(56)
If b(13, j56) = 0 Then b(13, j56) = j56: c(13, 4) = j56 Else GoTo 560
a(56) = j56 - 1

For j55 = 1 To 4                                                     'a(55)
If b(13, j55) = 0 Then b(13, j55) = j55: c(13, 3) = j55 Else GoTo 550
a(55) = j55 - 1

For j54 = 1 To 4                                                     'a(54)
If b(12, j54) = 0 Then b(12, j54) = j54: c(12, 4) = j54 Else GoTo 540
a(54) = j54 - 1

For j53 = 1 To 4                                                     'a(53)
If b(12, j53) = 0 Then b(12, j53) = j53: c(12, 3) = j53 Else GoTo 530
a(53) = j53 - 1

For j52 = 1 To 4                                                     'a(52)
If b(11, j52) = 0 Then b(11, j52) = j52: c(11, 4) = j52 Else GoTo 520
a(52) = j52 - 1

a(51) = 15 - a(52) - a(53) - a(54) - a(55) - a(56) - a(57) - a(58) - a(59) - a(60)
j51 = a(51) + 1: If j51 <= 0 Or j51 > 4 Then GoTo 510
If b(11, j51) = 0 Then b(11, j51) = j51: c(11, 3) = j51 Else GoTo 510

'   Check Hor Axes 1
    GoSub 3300: If fl1 = 0 Then GoTo 505

For j50 = 1 To 4                                                     'a(50)
If b(15, j50) = 0 Then b(15, j50) = j50: c(15, 2) = j50 Else GoTo 500
a(50) = j50 - 1
a(49) = 6 - a(50) - a(59) - a(60)
j49 = a(49) + 1: If j49 <= 0 Or j49 > 4 Then GoTo 490
If b(15, j49) = 0 Then b(15, j49) = j49: c(15, 1) = j49 Else GoTo 490

For j48 = 1 To 4                                                     'a(48)
If b(14, j48) = 0 Then b(14, j48) = j48: c(14, 2) = j48 Else GoTo 480
a(48) = j48 - 1
a(47) = 6 - a(48) - a(57) - a(58)
j47 = a(47) + 1: If j47 <= 0 Or j47 > 4 Then GoTo 470
If b(14, j47) = 0 Then b(14, j47) = j47: c(14, 1) = j47 Else GoTo 470

For j46 = 1 To 4                                                     'a(46)
If b(13, j46) = 0 Then b(13, j46) = j46: c(13, 2) = j46 Else GoTo 460
a(46) = j46 - 1
a(45) = 6 - a(46) - a(55) - a(56)
j45 = a(45) + 1: If j45 <= 0 Or j45 > 4 Then GoTo 450
If b(13, j45) = 0 Then b(13, j45) = j45: c(13, 1) = j45 Else GoTo 450

For j44 = 1 To 4                                                     'a(44)
If b(12, j44) = 0 Then b(12, j44) = j44: c(12, 2) = j44 Else GoTo 440
a(44) = j44 - 1
a(43) = 6 - a(44) - a(53) - a(54)
j43 = a(43) + 1: If j43 <= 0 Or j43 > 4 Then GoTo 430
If b(12, j43) = 0 Then b(12, j43) = j43: c(12, 1) = j43 Else GoTo 430

For j42 = 1 To 4                                                     'a(42)
If b(11, j42) = 0 Then b(11, j42) = j42: c(11, 2) = j42 Else GoTo 420
a(42) = j42 - 1
a(41) = 6 - a(42) - a(51) - a(52)
j41 = a(41) + 1: If j41 <= 0 Or j41 > 4 Then GoTo 410
If b(11, j41) = 0 Then b(11, j41) = j41: c(11, 1) = j41 Else GoTo 410

' Check Hor Axes 2
  GoSub 3400: If fl1 = 0 Then GoTo 405

For j96 = 1 To 4                                                     'a(96)
If b(23, j96) = 0 Then b(23, j96) = j96: c(23, 4) = j96 Else GoTo 960
a(96) = j96 - 1

For j95 = 1 To 4                                                     'a(95)
If b(23, j95) = 0 Then b(23, j95) = j95: c(23, 3) = j95 Else GoTo 950
a(95) = j95 - 1

For j86 = 1 To 4                                                     'a(86)
If b(23, j86) = 0 Then b(23, j86) = j86: c(23, 2) = j86 Else GoTo 860
a(86) = j86 - 1
a(85) = 6 - a(86) - a(95) - a(96)
j85 = a(85) + 1: If j85 <= 0 Or j85 > 4 Then GoTo 850
If b(23, j85) = 0 Then b(23, j85) = j85: c(23, 1) = j85 Else GoTo 850

For j76 = 1 To 4                                                     'a(76)
If b(18, j76) = 0 Then b(18, j76) = j76: c(18, 4) = j76 Else GoTo 760
a(76) = j76 - 1

For j75 = 1 To 4                                                     'a(75)
If b(18, j75) = 0 Then b(18, j75) = j75: c(18, 3) = j75 Else GoTo 750
a(75) = j75 - 1

For j66 = 1 To 4                                                     'a(66)
If b(18, j66) = 0 Then b(18, j66) = j66: c(18, 2) = j66 Else GoTo 660
a(66) = j66 - 1
a(65) = 6 - a(66) - a(75) - a(76)
j65 = a(65) + 1: If j65 <= 0 Or j65 > 4 Then GoTo 650
If b(18, j65) = 0 Then b(18, j65) = j65: c(18, 1) = j65 Else GoTo 650

For j36 = 1 To 4                                                     'a(36)
If b(8, j36) = 0 Then b(8, j36) = j36: c(8, 4) = j36 Else GoTo 360
a(36) = j36 - 1

For j35 = 1 To 4                                                     'a(35)
If b(8, j35) = 0 Then b(8, j35) = j35: c(8, 3) = j35 Else GoTo 350
a(35) = j35 - 1

For j26 = 1 To 4                                                     'a(26)
If b(8, j26) = 0 Then b(8, j26) = j26: c(8, 2) = j26 Else GoTo 260
a(26) = j26 - 1
a(25) = 6 - a(26) - a(35) - a(36)
j25 = a(25) + 1: If j25 <= 0 Or j25 > 4 Then GoTo 250
If b(8, j25) = 0 Then b(8, j25) = j25: c(8, 1) = j25 Else GoTo 250

For j16 = 1 To 4                                                     'a(16)
If b(3, j16) = 0 Then b(3, j16) = j16: c(3, 4) = j16 Else GoTo 160
a(16) = j16 - 1

a(6) = 15 - a(16) - a(26) - a(36) - a(46) - a(56) - a(66) - a(76) - a(86) - a(96)
j6 = a(6) + 1: If j6 <= 0 Or j6 > 4 Then GoTo 60
If b(3, j6) = 0 Then b(3, j6) = j6: c(3, 2) = j6 Else GoTo 60

'   Check Vert Axes 1
    GoSub 3600: If fl1 = 0 Then GoTo 55

For j15 = 1 To 4                                                     'a(15)
If b(3, j15) = 0 Then b(3, j15) = j15: c(3, 3) = j15 Else GoTo 150
a(15) = j15 - 1

a(5) = 6 - a(6) - a(15) - a(16)
j5 = a(5) + 1: If j5 <= 0 Or j5 > 4 Then GoTo 50
If b(3, j5) = 0 Then b(3, j5) = j5: c(3, 1) = j5 Else GoTo 50

'   Check Vert Axes 2
    GoSub 3500: If fl1 = 0 Then GoTo 45

For j100 = 1 To 4                                                    'a(100)
If b(25, j100) = 0 Then b(25, j100) = j100: c(25, 4) = j100 Else GoTo 1000
a(100) = j100 - 1

For j99 = 1 To 4                                                     'a(99)
If b(25, j99) = 0 Then b(25, j99) = j99: c(25, 3) = j99 Else GoTo 990
a(99) = j99 - 1

For j98 = 1 To 4                                                     'a(98)
If b(24, j98) = 0 Then b(24, j98) = j98: c(24, 4) = j98 Else GoTo 980
a(98) = j98 - 1

For j97 = 1 To 4                                                     'a(97)
If b(24, j97) = 0 Then b(24, j97) = j97: c(24, 3) = j97 Else GoTo 970
a(97) = j97 - 1

For j94 = 1 To 4                                                     'a(94)
If b(22, j94) = 0 Then b(22, j94) = j94: c(22, 4) = j94 Else GoTo 940
a(94) = j94 - 1

For j93 = 1 To 4                                                     'a(93)
If b(22, j93) = 0 Then b(22, j93) = j93: c(22, 3) = j93 Else GoTo 930
a(93) = j93 - 1

For j92 = 1 To 4                                                     'a(92)
If b(21, j92) = 0 Then b(21, j92) = j92: c(21, 4) = j92 Else GoTo 920
a(92) = j92 - 1
a(91) = 15 - a(92) - a(93) - a(94) - a(95) - a(96) - a(97) - a(98) - a(99) - a(100)
j91 = a(91) + 1: If j91 <= 0 Or j91 > 4 Then GoTo 910
If b(21, j91) = 0 Then b(21, j91) = j91: c(21, 3) = j91 Else GoTo 910

For j90 = 1 To 4                                                     'a(90)
If b(25, j90) = 0 Then b(25, j90) = j90: c(25, 2) = j90 Else GoTo 900
a(90) = j90 - 1
a(89) = 6 - a(90) - a(99) - a(100)
j89 = a(89) + 1: If j89 <= 0 Or j89 > 4 Then GoTo 890
If b(25, j89) = 0 Then b(25, j89) = j89: c(25, 1) = j89 Else GoTo 890

For j88 = 1 To 4                                                     'a(88)
If b(24, j88) = 0 Then b(24, j88) = j88: c(24, 2) = j88 Else GoTo 880
a(88) = j88 - 1
a(87) = 6 - a(88) - a(97) - a(98)
j87 = a(87) + 1: If j87 <= 0 Or j87 > 4 Then GoTo 870
If b(24, j87) = 0 Then b(24, j87) = j87: c(24, 1) = j87 Else GoTo 870

For j84 = 1 To 4                                                     'a(84)
If b(22, j84) = 0 Then b(22, j84) = j84: c(22, 2) = j84 Else GoTo 840
a(84) = j84 - 1
a(83) = 6 - a(84) - a(93) - a(94)
j83 = a(83) + 1: If j83 <= 0 Or j83 > 4 Then GoTo 830
If b(22, j83) = 0 Then b(22, j83) = j83: c(22, 1) = j83 Else GoTo 830

For j82 = 1 To 4                                                     'a(82)
If b(21, j82) = 0 Then b(21, j82) = j82: c(21, 2) = j82 Else GoTo 820
a(82) = j82 - 1
a(81) = 6 - a(82) - a(91) - a(92)
j81 = a(81) + 1: If j81 <= 0 Or j81 > 4 Then GoTo 810
If b(21, j81) = 0 Then b(21, j81) = j81: c(21, 1) = j81 Else GoTo 810

For j80 = 1 To 4                                                    'a(80)
If b(20, j80) = 0 Then b(20, j80) = j80: c(20, 4) = j80 Else GoTo 800
a(80) = j80 - 1

For j79 = 1 To 4                                                     'a(79)
If b(20, j79) = 0 Then b(20, j79) = j79: c(20, 3) = j79 Else GoTo 790
a(79) = j79 - 1

For j78 = 1 To 4                                                     'a(78)
If b(19, j78) = 0 Then b(19, j78) = j78: c(19, 4) = j78 Else GoTo 780
a(78) = j78 - 1

For j77 = 1 To 4                                                     'a(77)
If b(19, j77) = 0 Then b(19, j77) = j77: c(19, 3) = j77 Else GoTo 770
a(77) = j77 - 1

For j74 = 1 To 4                                                     'a(74)
If b(17, j74) = 0 Then b(17, j74) = j74: c(17, 4) = j74 Else GoTo 740
a(74) = j74 - 1

For j73 = 1 To 4                                                     'a(73)
If b(17, j73) = 0 Then b(17, j73) = j73: c(17, 3) = j73 Else GoTo 730
a(73) = j73 - 1

For j72 = 1 To 4                                                     'a(72)
If b(16, j72) = 0 Then b(16, j72) = j72: c(16, 4) = j72 Else GoTo 720
a(72) = j72 - 1
a(71) = 15 - a(72) - a(73) - a(74) - a(75) - a(76) - a(77) - a(78) - a(79) - a(80)
j71 = a(71) + 1: If j71 <= 0 Or j71 > 4 Then GoTo 710
If b(16, j71) = 0 Then b(16, j71) = j71: c(16, 3) = j71 Else GoTo 710

For j70 = 1 To 4                                                     'a(70)
If b(20, j70) = 0 Then b(20, j70) = j70: c(20, 2) = j70 Else GoTo 700
a(70) = j70 - 1
a(69) = 6 - a(70) - a(79) - a(80)
j69 = a(69) + 1: If j69 <= 0 Or j69 > 4 Then GoTo 690
If b(20, j69) = 0 Then b(20, j69) = j69: c(20, 1) = j69 Else GoTo 690

For j68 = 1 To 4                                                     'a(68)
If b(19, j68) = 0 Then b(19, j68) = j68: c(19, 2) = j68 Else GoTo 680
a(68) = j68 - 1
a(67) = 6 - a(68) - a(77) - a(78)
j67 = a(67) + 1: If j67 <= 0 Or j67 > 4 Then GoTo 670
If b(19, j67) = 0 Then b(19, j67) = j67: c(19, 1) = j67 Else GoTo 670

For j64 = 1 To 4                                                     'a(64)
If b(17, j64) = 0 Then b(17, j64) = j64: c(17, 2) = j64 Else GoTo 640
a(64) = j64 - 1
a(63) = 6 - a(64) - a(73) - a(74)
j63 = a(63) + 1: If j63 <= 0 Or j63 > 4 Then GoTo 630
If b(17, j63) = 0 Then b(17, j63) = j63: c(17, 1) = j63 Else GoTo 630

For j62 = 1 To 4                                                     'a(62)
If b(16, j62) = 0 Then b(16, j62) = j62: c(16, 2) = j62 Else GoTo 620
a(62) = j62 - 1
a(61) = 6 - a(62) - a(71) - a(72)
j61 = a(61) + 1: If j61 <= 0 Or j61 > 4 Then GoTo 610
If b(16, j61) = 0 Then b(16, j61) = j61: c(16, 1) = j61 Else GoTo 610

For j40 = 1 To 4                                                    'a(40)
If b(10, j40) = 0 Then b(10, j40) = j40: c(10, 4) = j40 Else GoTo 400
a(40) = j40 - 1

For j39 = 1 To 4                                                     'a(39)
If b(10, j39) = 0 Then b(10, j39) = j39: c(10, 3) = j39 Else GoTo 390
a(39) = j39 - 1

For j38 = 1 To 4                                                     'a(38)
If b(9, j38) = 0 Then b(9, j38) = j38: c(9, 4) = j38 Else GoTo 380
a(38) = j38 - 1

For j37 = 1 To 4                                                     'a(37)
If b(9, j37) = 0 Then b(9, j37) = j37: c(9, 3) = j37 Else GoTo 370
a(37) = j37 - 1

For j34 = 1 To 4                                                     'a(34)
If b(7, j34) = 0 Then b(7, j34) = j34: c(7, 4) = j34 Else GoTo 340
a(34) = j34 - 1

For j33 = 1 To 4                                                     'a(33)
If b(7, j33) = 0 Then b(7, j33) = j33: c(7, 3) = j33 Else GoTo 330
a(33) = j33 - 1

For j32 = 1 To 4                                                     'a(32)
If b(6, j32) = 0 Then b(6, j32) = j32: c(6, 4) = j32 Else GoTo 320
a(32) = j32 - 1
a(31) = 15 - a(32) - a(33) - a(34) - a(35) - a(36) - a(37) - a(38) - a(39) - a(40)
j31 = a(31) + 1: If j31 <= 0 Or j31 > 4 Then GoTo 310
If b(6, j31) = 0 Then b(6, j31) = j31: c(6, 3) = j31 Else GoTo 310

For j30 = 1 To 4                                                     'a(30)
If b(10, j30) = 0 Then b(10, j30) = j30: c(10, 2) = j30 Else GoTo 300
a(30) = j30 - 1
a(29) = 6 - a(30) - a(39) - a(40)
j29 = a(29) + 1: If j29 <= 0 Or j29 > 4 Then GoTo 290
If b(10, j29) = 0 Then b(10, j29) = j29: c(10, 1) = j29 Else GoTo 290

For j28 = 1 To 4                                                     'a(28)
If b(9, j28) = 0 Then b(9, j28) = j28: c(9, 2) = j28 Else GoTo 280
a(28) = j28 - 1
a(27) = 6 - a(28) - a(37) - a(38)
j27 = a(27) + 1: If j27 <= 0 Or j27 > 4 Then GoTo 270
If b(9, j27) = 0 Then b(9, j27) = j27: c(9, 1) = j27 Else GoTo 270

For j24 = 1 To 4                                                     'a(24)
If b(7, j24) = 0 Then b(7, j24) = j24: c(7, 2) = j24 Else GoTo 240
a(24) = j24 - 1
a(23) = 6 - a(24) - a(33) - a(34)
j23 = a(23) + 1: If j23 <= 0 Or j23 > 4 Then GoTo 230
If b(7, j23) = 0 Then b(7, j23) = j23: c(7, 1) = j23 Else GoTo 230

For j22 = 1 To 4                                                     'a(22)
If b(6, j22) = 0 Then b(6, j22) = j22: c(6, 2) = j22 Else GoTo 220
a(22) = j22 - 1
a(21) = 6 - a(22) - a(31) - a(32)
j21 = a(21) + 1: If j21 <= 0 Or j21 > 4 Then GoTo 210
If b(6, j21) = 0 Then b(6, j21) = j21: c(6, 1) = j21 Else GoTo 210

For j20 = 1 To 4                                                    'a(20)
If b(5, j20) = 0 Then b(5, j20) = j20: c(5, 4) = j20 Else GoTo 200
a(20) = j20 - 1

a(19) = 18 + a(20) - a(28) + a(30) - a(37) + a(40) - a(46) - a(49) - a(55) - a(59) - a(64) - a(69) - a(73) - a(79) - a(82) - a(89) - a(91) - a(99)
j19 = a(19) + 1: If j19 <= 0 Or j19 > 4 Then GoTo 190
If b(5, j19) = 0 Then b(5, j19) = j19: c(5, 3) = j19 Else GoTo 190

a(10) = 15 - a(20) - a(30) - a(40) - a(50) - a(60) - a(70) - a(80) - a(90) - a(100)
j10 = a(10) + 1: If j10 <= 0 Or j10 > 4 Then GoTo 100
If b(5, j10) = 0 Then b(5, j10) = j10: c(5, 2) = j10 Else GoTo 100

a(9) = 6 - a(10) - a(19) - a(20)
j9 = a(9) + 1: If j9 <= 0 Or j9 > 4 Then GoTo 90
If b(5, j9) = 0 Then b(5, j9) = j9: c(5, 1) = j9 Else GoTo 90

For j18 = 1 To 4                                                     'a(18)
If b(4, j18) = 0 Then b(4, j18) = j18: c(4, 4) = j18 Else GoTo 180
a(18) = j18 - 1

a(8) = 15 - a(18) - a(28) - a(38) - a(48) - a(58) - a(68) - a(78) - a(88) - a(98)
j8 = a(8) + 1: If j8 <= 0 Or j8 > 4 Then GoTo 80
If b(4, j8) = 0 Then b(4, j8) = j8: c(4, 2) = j8 Else GoTo 80

For j17 = 1 To 4                                                     'a(17)
If b(4, j17) = 0 Then b(4, j17) = j17: c(4, 3) = j17 Else GoTo 170
a(17) = j17 - 1

a(7) = 6 - a(8) - a(17) - a(18)
j7 = a(7) + 1: If j7 <= 0 Or j7 > 4 Then GoTo 70
If b(4, j7) = 0 Then b(4, j7) = j7: c(4, 1) = j7 Else GoTo 70

For j14 = 1 To 4                                                     'a(14)
If b(2, j14) = 0 Then b(2, j14) = j14: c(2, 4) = j14 Else GoTo 140
a(14) = j14 - 1

a(4) = 15 - a(14) - a(24) - a(34) - a(44) - a(54) - a(64) - a(74) - a(84) - a(94)
j4 = a(4) + 1: If j4 <= 0 Or j4 > 4 Then GoTo 40
If b(2, j4) = 0 Then b(2, j4) = j4: c(2, 2) = j4 Else GoTo 40

For j13 = 1 To 4                                                     'a(13)
If b(2, j13) = 0 Then b(2, j13) = j13: c(2, 3) = j13 Else GoTo 130
a(13) = j13 - 1

a(12) = (15-a(13)-a(14)-a(15)-a(16)-a(17)-a(18)-2*a(20)-a(22)+a(24)+a(28)-a(30)-a(32)+a(33)+a(37)-a(40)-a(42)-a(45)+a(46)+a(49)-a(52) +
+ a(55)-a(56)+a(59)-a(62)+a(64)-a(67)+a(69)-a(72)+a(73)-a(78)+a(79)+a(91)-a(92)+a(99)-a(100)) / 2

j12 = a(12) + 1: If j12 <= 0 Or j12 > 4 Or Int(a(12)) <> a(12) Then GoTo 120
If b(1, j12) = 0 Then b(1, j12) = j12: c(1, 4) = j12 Else GoTo 120

a(11) = 15 - a(12) - a(13) - a(14) - a(15) - a(16) - a(17) - a(18) - a(19) - a(20)
j11 = a(11) + 1: If j11 <= 0 Or j11 > 4 Then GoTo 110
If b(1, j11) = 0 Then b(1, j11) = j11: c(1, 3) = j11 Else GoTo 110

a(3) = 6 - a(4) - a(13) - a(14)
j3 = a(3) + 1: If j3 <= 0 Or j3 > 4 Then GoTo 30
If b(2, j3) = 0 Then b(2, j3) = j3: c(2, 1) = j3 Else GoTo 30

a(2) = 15 - a(12) - a(22) - a(32) - a(42) - a(52) - a(62) - a(72) - a(82) - a(92)
j2 = a(2) + 1: If j2 <= 0 Or j2 > 4 Or Int(a(2)) <> a(2) Then GoTo 20
If b(1, j2) = 0 Then b(1, j2) = j2: c(1, 2) = j2 Else GoTo 20

a(1) = 6 - a(2) - a(11) - a(12)
j1 = a(1) + 1: If j1 <= 0 Or j1 > 4 Then GoTo 10
If b(1, j1) = 0 Then b(1, j1) = j1: c(1, 1) = j1 Else GoTo 10

'                           n9 = n9 + 1: GoSub 2645 'Print results (selected numbers)
                            n9 = n9 + 1: GoSub 2650 'Print results (Medjig Squares)
'                           n9 = n9 + 1: GoSub 2700 'Calculate and print Magic Square
                            Erase b, c: GoTo 1100

    b(1, c(1, 1)) = 0: c(1, 1) = 0
10  b(1, c(1, 2)) = 0: c(1, 2) = 0
20  b(2, c(2, 1)) = 0: c(2, 1) = 0
30  b(1, c(1, 3)) = 0: c(1, 3) = 0
110 b(1, c(1, 4)) = 0: c(1, 4) = 0
120 b(2, c(2, 3)) = 0: c(2, 3) = 0
130 Next j13
    b(2, c(2, 2)) = 0: c(2, 2) = 0
40  b(2, c(2, 4)) = 0: c(2, 4) = 0
140 Next j14

    b(4, c(4, 1)) = 0: c(4, 1) = 0
70  b(4, c(4, 3)) = 0: c(4, 3) = 0
170 Next j17
    b(4, c(4, 2)) = 0: c(4, 2) = 0
80  b(4, c(4, 4)) = 0: c(4, 4) = 0
180 Next j18

    b(5, c(5, 1)) = 0: c(5, 1) = 0
90  b(5, c(5, 2)) = 0: c(5, 2) = 0
100 b(5, c(5, 3)) = 0: c(5, 3) = 0
190 b(5, c(5, 4)) = 0: c(5, 4) = 0
200 Next j20

    b(6, c(6, 1)) = 0: c(6, 1) = 0
210 b(6, c(6, 2)) = 0: c(6, 2) = 0
220 Next j22
    b(7, c(7, 1)) = 0: c(7, 1) = 0
230 b(7, c(7, 2)) = 0: c(7, 2) = 0
240 Next j24
    b(9, c(9, 1)) = 0: c(9, 1) = 0
270 b(9, c(9, 2)) = 0: c(9, 2) = 0
280 Next j28
    b(10, c(10, 1)) = 0: c(10, 1) = 0
290 b(10, c(10, 2)) = 0: c(10, 2) = 0
300 Next j30

    b(6, c(6, 3)) = 0: c(6, 3) = 0
310 b(6, c(6, 4)) = 0: c(6, 4) = 0
320 Next j32
    b(7, c(7, 3)) = 0: c(7, 3) = 0
330 Next j33
    b(7, c(7, 4)) = 0: c(7, 4) = 0
340 Next j34
    b(9, c(9, 3)) = 0: c(9, 3) = 0
370 Next j37
    b(9, c(9, 4)) = 0: c(9, 4) = 0
380 Next j38
    b(10, c(10, 3)) = 0: c(10, 3) = 0
390 Next j39
    b(10, c(10, 4)) = 0: c(10, 4) = 0
400 Next j40

    b(16, c(16, 1)) = 0: c(16, 1) = 0
610 b(16, c(16, 2)) = 0: c(16, 2) = 0
620 Next j62
    b(17, c(17, 1)) = 0: c(17, 1) = 0
630 b(17, c(17, 2)) = 0: c(17, 2) = 0
640 Next j64
    b(19, c(19, 1)) = 0: c(19, 1) = 0
670 b(19, c(19, 2)) = 0: c(19, 2) = 0
680 Next j68
    b(20, c(20, 1)) = 0: c(20, 1) = 0
690 b(20, c(20, 2)) = 0: c(20, 2) = 0
700 Next j70

    b(16, c(16, 3)) = 0: c(16, 3) = 0
710 b(16, c(16, 4)) = 0: c(16, 4) = 0
720 Next j72
    b(17, c(17, 3)) = 0: c(17, 3) = 0
730 Next j73
    b(17, c(17, 4)) = 0: c(17, 4) = 0
740 Next j74
    b(19, c(19, 3)) = 0: c(19, 3) = 0
770 Next j77
    b(19, c(19, 4)) = 0: c(19, 4) = 0
780 Next j78
    b(20, c(20, 3)) = 0: c(20, 3) = 0
790 Next j79
     b(20, c(20, 4)) = 0: c(20, 4) = 0
800 Next j80

    b(21, c(21, 1)) = 0: c(21, 1) = 0
810 b(21, c(21, 2)) = 0: c(21, 2) = 0
820 Next j82
    b(22, c(22, 1)) = 0: c(22, 1) = 0
830 b(22, c(22, 2)) = 0: c(22, 2) = 0
840 Next j84
    b(24, c(24, 1)) = 0: c(24, 1) = 0
870 b(24, c(24, 2)) = 0: c(24, 2) = 0
880 Next j88
    b(25, c(25, 1)) = 0: c(25, 1) = 0
890 b(25, c(25, 2)) = 0: c(25, 2) = 0
900 Next j90

    b(21, c(21, 3)) = 0: c(21, 3) = 0
910 b(21, c(21, 4)) = 0: c(21, 4) = 0
920 Next j92
    b(22, c(22, 3)) = 0: c(22, 3) = 0
930 Next j93
    b(22, c(22, 4)) = 0: c(22, 4) = 0
940 Next j94
    b(24, c(24, 3)) = 0: c(24, 3) = 0
970 Next j97
    b(24, c(24, 4)) = 0: c(24, 4) = 0
980 Next j98
    b(25, c(25, 3)) = 0: c(25, 3) = 0
990 Next j99
     b(25, c(25, 4)) = 0: c(25, 4) = 0
1000 Next j100

45
    b(3, c(3, 1)) = 0: c(3, 1) = 0
50  b(3, c(3, 3)) = 0: c(3, 3) = 0
150 Next j15

55
    b(3, c(3, 2)) = 0: c(3, 2) = 0
60  b(3, c(3, 4)) = 0: c(3, 4) = 0
160 Next j16

    b(8, c(8, 1)) = 0: c(8, 1) = 0
250 b(8, c(8, 2)) = 0: c(8, 2) = 0
260 Next j26
    b(8, c(8, 3)) = 0: c(8, 3) = 0
350 Next j35
    b(8, c(8, 4)) = 0: c(8, 4) = 0
360 Next j36

    b(18, c(18, 1)) = 0: c(18, 1) = 0
650 b(18, c(18, 2)) = 0: c(18, 2) = 0
660 Next j66
    b(18, c(18, 3)) = 0: c(18, 3) = 0
750 Next j75
    b(18, c(18, 4)) = 0: c(18, 4) = 0
760 Next j76

    b(23, c(23, 1)) = 0: c(23, 1) = 0
850 b(23, c(23, 2)) = 0: c(23, 2) = 0
860 Next j86
    b(23, c(23, 3)) = 0: c(23, 3) = 0
950 Next j95
    b(23, c(23, 4)) = 0: c(23, 4) = 0
960 Next j96

405

    b(11, c(11, 1)) = 0: c(11, 1) = 0
410 b(11, c(11, 2)) = 0: c(11, 2) = 0
420 Next j42
    b(12, c(12, 1)) = 0: c(12, 1) = 0
430 b(12, c(12, 2)) = 0: c(12, 2) = 0
440 Next j44
    b(13, c(13, 1)) = 0: c(13, 1) = 0
450 b(13, c(13, 2)) = 0: c(13, 2) = 0
460 Next j46
    b(14, c(14, 1)) = 0: c(14, 1) = 0
470 b(14, c(14, 2)) = 0: c(14, 2) = 0
480 Next j48
    b(15, c(15, 1)) = 0: c(15, 1) = 0
490 b(15, c(15, 2)) = 0: c(15, 2) = 0
500 Next j50

505
    b(11, c(11, 3)) = 0: c(11, 3) = 0
510 b(11, c(11, 4)) = 0: c(11, 4) = 0
520 Next j52
    b(12, c(12, 3)) = 0: c(12, 3) = 0
530 Next j53
    b(12, c(12, 4)) = 0: c(12, 4) = 0
540 Next j54
    b(13, c(13, 3)) = 0: c(13, 3) = 0
550 Next j55
    b(13, c(13, 4)) = 0: c(13, 4) = 0
560 Next j56
    b(14, c(14, 3)) = 0: c(14, 3) = 0
570 Next j57
    b(14, c(14, 4)) = 0: c(14, 4) = 0
580 Next j58
    b(15, c(15, 3)) = 0: c(15, 3) = 0
590 Next j59
     b(15, c(15, 4)) = 0: c(15, 4) = 0
600 Next j60

1100 Next j110

     t2 = Timer
     t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Combinations"
     y = MsgBox(t10, 0, "Routine MgcSqr10a3")

End

Return

'    Print results (selected numbers)

2645 For i1 = 1 To 100
        Cells(n9, i1).Value = a(i1)
     Next i1
    
     Return

'    Print results (squares)

2650 n2 = n2 + 1
     If n2 = 5 Then
         n2 = 1: k1 = k1 + 11: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 11
     End If

     Cells(k1, k2 + 1).Select
     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = CStr(j110)

     i3 = 0
     For i1 = 1 To 10
         For i2 = 1 To 10
             i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = a(i3)
         Next i2
     Next i1

     Return

'    Calculate and print Magic Square

2700 c1(1) = b1(1) + 25 * a(1): c1(2) = b1(1) + 25 * a(2): c1(3) = b1(2) + 25 * a(3): c1(4) = b1(2) + 25 * a(4): c1(5) = b1(3) + 25 * a(5)
     c1(6) = b1(3) + 25 * a(6): c1(7) = b1(4) + 25 * a(7): c1(8) = b1(4) + 25 * a(8): c1(9) = b1(5) + 25 * a(9): c1(10) = b1(5) + 25 * a(10)
     
     c1(11) = b1(1) + 25 * a(11): c1(12) = b1(1) + 25 * a(12): c1(13) = b1(2) + 25 * a(13): c1(14) = b1(2) + 25 * a(14): c1(15) = b1(3) + 25 * a(15)
     c1(16) = b1(3) + 25 * a(16): c1(17) = b1(4) + 25 * a(17): c1(18) = b1(4) + 25 * a(18): c1(19) = b1(5) + 25 * a(19): c1(20) = b1(5) + 25 * a(20)
     
     c1(21) = b1(6) + 25 * a(21): c1(22) = b1(6) + 25 * a(22): c1(23) = b1(7) + 25 * a(23): c1(24) = b1(7) + 25 * a(24): c1(25) = b1(8) + 25 * a(25)
     c1(26) = b1(8) + 25 * a(26): c1(27) = b1(9) + 25 * a(27): c1(28) = b1(9) + 25 * a(28): c1(29) = b1(10) + 25 * a(29): c1(30) = b1(10) + 25 * a(30)
     
     c1(31) = b1(6) + 25 * a(31): c1(32) = b1(6) + 25 * a(32): c1(33) = b1(7) + 25 * a(33): c1(34) = b1(7) + 25 * a(34): c1(35) = b1(8) + 25 * a(35)
     c1(36) = b1(8) + 25 * a(36): c1(37) = b1(9) + 25 * a(37): c1(38) = b1(9) + 25 * a(38): c1(39) = b1(10) + 25 * a(39): c1(40) = b1(10) + 25 * a(40)
     
     c1(41) = b1(11) + 25 * a(41): c1(42) = b1(11) + 25 * a(42): c1(43) = b1(12) + 25 * a(43): c1(44) = b1(12) + 25 * a(44): c1(45) = b1(13) + 25 * a(45)
     c1(46) = b1(13) + 25 * a(46): c1(47) = b1(14) + 25 * a(47): c1(48) = b1(14) + 25 * a(48): c1(49) = b1(15) + 25 * a(49): c1(50) = b1(15) + 25 * a(50)
     
     c1(51) = b1(11) + 25 * a(51): c1(52) = b1(11) + 25 * a(52): c1(53) = b1(12) + 25 * a(53): c1(54) = b1(12) + 25 * a(54): c1(55) = b1(13) + 25 * a(55)
     c1(56) = b1(13) + 25 * a(56): c1(57) = b1(14) + 25 * a(57): c1(58) = b1(14) + 25 * a(58): c1(59) = b1(15) + 25 * a(59): c1(60) = b1(15) + 25 * a(60)
     
     c1(61) = b1(16) + 25 * a(61): c1(62) = b1(16) + 25 * a(62): c1(63) = b1(17) + 25 * a(63): c1(64) = b1(17) + 25 * a(64): c1(65) = b1(18) + 25 * a(65)
     c1(66) = b1(18) + 25 * a(66): c1(67) = b1(19) + 25 * a(67): c1(68) = b1(19) + 25 * a(68): c1(69) = b1(20) + 25 * a(69): c1(70) = b1(20) + 25 * a(70)
     
     c1(71) = b1(16) + 25 * a(71): c1(72) = b1(16) + 25 * a(72): c1(73) = b1(17) + 25 * a(73): c1(74) = b1(17) + 25 * a(74): c1(75) = b1(18) + 25 * a(75)
     c1(76) = b1(18) + 25 * a(76): c1(77) = b1(19) + 25 * a(77): c1(78) = b1(19) + 25 * a(78): c1(79) = b1(20) + 25 * a(79): c1(80) = b1(20) + 25 * a(80)
     
     c1(81) = b1(21) + 25 * a(81): c1(82) = b1(21) + 25 * a(82): c1(83) = b1(22) + 25 * a(83): c1(84) = b1(22) + 25 * a(84): c1(85) = b1(23) + 25 * a(85)
     c1(86) = b1(23) + 25 * a(86): c1(87) = b1(24) + 25 * a(87): c1(88) = b1(24) + 25 * a(88): c1(89) = b1(25) + 25 * a(89): c1(90) = b1(25) + 25 * a(90)
     
     c1(91) = b1(21) + 25 * a(91): c1(92) = b1(21) + 25 * a(92): c1(93) = b1(22) + 25 * a(93): c1(94) = b1(22) + 25 * a(94): c1(95) = b1(23) + 25 * a(95)
     c1(96) = b1(23) + 25 * a(96): c1(97) = b1(24) + 25 * a(97): c1(98) = b1(24) + 25 * a(98): c1(99) = b1(25) + 25 * a(99): c1(100) = b1(25) + 25 * a(100)
           
     n2 = n2 + 1
     If n2 = 5 Then
         n2 = 1: k1 = k1 + 11: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 11
     End If

     Cells(k1, k2 + 1).Select
     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = CStr(j110)

     i3 = 0
     For i1 = 1 To 10
         For i2 = 1 To 10
             i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = c1(i3)
         Next i2
     Next i1
  
     Return

'    Check Bimagic Hor Axes 1
     
3300 fl1 = 1: s2 = 0

     c10(1) = b1(11) + 25 * a(51):
     c10(2) = b1(11) + 25 * a(52):
     c10(3) = b1(12) + 25 * a(53):
     c10(4) = b1(12) + 25 * a(54):
     c10(5) = b1(13) + 25 * a(55):
     c10(6) = b1(13) + 25 * a(56):
     c10(7) = b1(14) + 25 * a(57):
     c10(8) = b1(14) + 25 * a(58):
     c10(9) = b1(15) + 25 * a(59):
     c10(10) = b1(15) + 25 * a(60):

     For i1 = 1 To 10
         s2 = s2 + c10(i1) ^ 2
     Next i1
     If s2 <> 33835 Then fl1 = 0
     
     Return

'    Check Bimagic Hor Axes 2
     
3400 fl1 = 1: s2 = 0

     c10(1) = b1(11) + 25 * a(41):
     c10(2) = b1(11) + 25 * a(42):
     c10(3) = b1(12) + 25 * a(43):
     c10(4) = b1(12) + 25 * a(44):
     c10(5) = b1(13) + 25 * a(45):
     c10(6) = b1(13) + 25 * a(46):
     c10(7) = b1(14) + 25 * a(47):
     c10(8) = b1(14) + 25 * a(48):
     c10(9) = b1(15) + 25 * a(49):
     c10(10) = b1(15) + 25 * a(50):

     For i1 = 1 To 10
         s2 = s2 + c10(i1) ^ 2
     Next i1
     If s2 <> 33835 Then fl1 = 0
     
     Return

'    Check Bimagic Vert Axes 2
     
3500 fl1 = 1: s2 = 0

     c10(1) = b1(3) + 25 * a(5):
     c10(2) = b1(3) + 25 * a(15):
     c10(3) = b1(8) + 25 * a(25):
     c10(4) = b1(8) + 25 * a(35):
     c10(5) = b1(13) + 25 * a(45):
     c10(6) = b1(13) + 25 * a(55):
     c10(7) = b1(18) + 25 * a(65):
     c10(8) = b1(18) + 25 * a(75):
     c10(9) = b1(23) + 25 * a(85):
     c10(10) = b1(23) + 25 * a(95):

     For i1 = 1 To 10
         s2 = s2 + c10(i1) ^ 2
     Next i1
     If s2 <> 33835 Then fl1 = 0
     
     Return

'    Check Bimagic Vert Axes 1
     
3600 fl1 = 1: s2 = 0

     c10(1) = b1(3) + 25 * a(6):
     c10(2) = b1(3) + 25 * a(16):
     c10(3) = b1(8) + 25 * a(26):
     c10(4) = b1(8) + 25 * a(36):
     c10(5) = b1(13) + 25 * a(46):
     c10(6) = b1(13) + 25 * a(56):
     c10(7) = b1(18) + 25 * a(66):
     c10(8) = b1(18) + 25 * a(76):
     c10(9) = b1(23) + 25 * a(86):
     c10(10) = b1(23) + 25 * a(96):

     For i1 = 1 To 10
         s2 = s2 + c10(i1) ^ 2
     Next i1
     If s2 <> 33835 Then fl1 = 0
     
     Return

End Sub

Vorige Pagina About the Author