' Generates Medjig Squares of order 8, Magic Sum 12, Integers 0, 1, 2 and 3

' Tested with Office 2007 under Windows 7

```Sub MgcSqr8e()

Dim a(64), b1(16), c1(64), b(16, 4), c(16, 4)

' 4 x 4 square for corresponding 8 x 8 Magic Squares

b1(1) = 12: b1(2) = 13:  b1(3) = 3:   b1(4) = 6
b1(5) = 7:  b1(6) = 2:   b1(7) = 16:  b1(8) = 9
b1(9) = 14: b1(10) = 11: b1(11) = 5:  b1(12) = 4
b1(13) = 1: b1(14) = 8:  b1(15) = 10: b1(16) = 15

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

n2 = 0: n3 = 0: n9 = 0

'   Generate data

Sheets("Solutions1").Select

t1 = Timer

For j64 = 3 To 3                                                    'a(64)
If b(16, j64) = 0 Then b(16, j64) = j64: c(16, 4) = j64 Else GoTo 640
a(64) = j64 - 1
For j63 = 2 To 2                                                    'a(63)
If b(16, j63) = 0 Then b(16, j63) = j63: c(16, 3) = j63 Else GoTo 630
a(63) = j63 - 1
For j62 = 2 To 2                                                    'a(62)
If b(15, j62) = 0 Then b(15, j62) = j62: c(15, 4) = j62 Else GoTo 620
a(62) = j62 - 1
For j61 = 4 To 4                                                    'a(61)
If b(15, j61) = 0 Then b(15, j61) = j61: c(15, 3) = j61 Else GoTo 610
a(61) = j61 - 1
For j60 = 2 To 2                                                    'a(60)
If b(14, j60) = 0 Then b(14, j60) = j60: c(14, 4) = j60 Else GoTo 600
a(60) = j60 - 1
For j59 = 1 To 1                                                    'a(59)
If b(14, j59) = 0 Then b(14, j59) = j59: c(14, 3) = j59 Else GoTo 590
a(59) = j59 - 1
For j58 = 4 To 4                                                    'a(58)
If b(13, j58) = 0 Then b(13, j58) = j58: c(13, 4) = j58 Else GoTo 580
a(58) = j58 - 1
a(57) = 12 - a(58) - a(59) - a(60) - a(61) - a(62) - a(63) - a(64)
j57 = a(57) + 1
If j57 <= 0 Or j57 > 4 Then GoTo 570
If b(13, j57) = 0 Then b(13, j57) = j57: c(13, 3) = j57 Else GoTo 570

For j56 = 4 To 4                                                    'a(56)
If b(16, j56) = 0 Then b(16, j56) = j56: c(16, 2) = j56 Else GoTo 560
a(56) = j56 - 1
a(55) = 6 - a(56) - a(63) - a(64)
j55 = a(55) + 1
If j55 <= 0 Or j55 > 4 Then GoTo 550
If b(16, j55) = 0 Then b(16, j55) = j55: c(16, 1) = j55 Else GoTo 550
For j54 = 1 To 1                                                    'a(54)
If b(15, j54) = 0 Then b(15, j54) = j54: c(15, 2) = j54 Else GoTo 540
a(54) = j54 - 1
a(53) = 6 - a(54) - a(61) - a(62)
j53 = a(53) + 1
If j53 <= 0 Or j53 > 4 Then GoTo 530
If b(15, j53) = 0 Then b(15, j53) = j53: c(15, 1) = j53 Else GoTo 530
For j52 = 3 To 3                                                    'a(52)
If b(14, j52) = 0 Then b(14, j52) = j52: c(14, 2) = j52 Else GoTo 520
a(52) = j52 - 1
a(51) = 6 - a(52) - a(59) - a(60)
j51 = a(51) + 1
If j51 <= 0 Or j51 > 4 Then GoTo 510
If b(14, j51) = 0 Then b(14, j51) = j51: c(14, 1) = j51 Else GoTo 510
For j50 = 1 To 1                                                    'a(50)
If b(13, j50) = 0 Then b(13, j50) = j50: c(13, 2) = j50 Else GoTo 500
a(50) = j50 - 1
a(49) = 6 - a(50) - a(57) - a(58)
j49 = a(49) + 1
If j49 <= 0 Or j49 > 4 Then GoTo 490
If b(13, j49) = 0 Then b(13, j49) = j49: c(13, 1) = j49 Else GoTo 490

For j48 = 2 To 2                                                    'a(48)
If b(12, j48) = 0 Then b(12, j48) = j48: c(12, 4) = j48 Else GoTo 480
a(48) = j48 - 1
For j47 = 4 To 4                                                    'a(47)
If b(12, j47) = 0 Then b(12, j47) = j47: c(12, 3) = j47 Else GoTo 470
a(47) = j47 - 1
For j46 = 4 To 4                                                    'a(46)
If b(11, j46) = 0 Then b(11, j46) = j46: c(11, 4) = j46 Else GoTo 460
a(46) = j46 - 1
For j45 = 1 To 1                                                    'a(45)
If b(11, j45) = 0 Then b(11, j45) = j45: c(11, 3) = j45 Else GoTo 450
a(45) = j45 - 1
For j44 = 3 To 3                                                    'a(44)
If b(10, j44) = 0 Then b(10, j44) = j44: c(10, 4) = j44 Else GoTo 440
a(44) = j44 - 1
For j43 = 1 To 1                                                    'a(43)
If b(10, j43) = 0 Then b(10, j43) = j43: c(10, 3) = j43 Else GoTo 430
a(43) = j43 - 1
For j42 = 2 To 2                                                    'a(42)
If b(9, j42) = 0 Then b(9, j42) = j42: c(9, 4) = j42 Else GoTo 420
a(42) = j42 - 1
a(41) = 12 - a(42) - a(43) - a(44) - a(45) - a(46) - a(47) - a(48)
j41 = a(41) + 1
If j41 <= 0 Or j41 > 4 Then GoTo 410
If b(9, j41) = 0 Then b(9, j41) = j41: c(9, 3) = j41 Else GoTo 410

For j40 = 1 To 1                                                    'a(40)
If b(12, j40) = 0 Then b(12, j40) = j40: c(12, 2) = j40 Else GoTo 400
a(40) = j40 - 1
a(39) = 6 - a(40) - a(47) - a(48)
j39 = a(39) + 1
If j39 <= 0 Or j39 > 4 Then GoTo 390
If b(12, j39) = 0 Then b(12, j39) = j39: c(12, 1) = j39 Else GoTo 390
For j38 = 2 To 2                                                    'a(38)
If b(11, j38) = 0 Then b(11, j38) = j38: c(11, 2) = j38 Else GoTo 380
a(38) = j38 - 1
a(37) = 6 - a(38) - a(45) - a(46)
j37 = a(37) + 1
If j37 <= 0 Or j37 > 4 Then GoTo 370
If b(11, j37) = 0 Then b(11, j37) = j37: c(11, 1) = j37 Else GoTo 370
For j36 = 4 To 4                                                    'a(36)
If b(10, j36) = 0 Then b(10, j36) = j36: c(10, 2) = j36 Else GoTo 360
a(36) = j36 - 1
a(35) = 6 - a(36) - a(43) - a(44)
j35 = a(35) + 1
If j35 <= 0 Or j35 > 4 Then GoTo 350
If b(10, j35) = 0 Then b(10, j35) = j35: c(10, 1) = j35 Else GoTo 350
For j34 = 1 To 1                                                    'a(34)
If b(9, j34) = 0 Then b(9, j34) = j34: c(9, 2) = j34 Else GoTo 340
a(34) = j34 - 1
a(33) = 6 - a(34) - a(41) - a(42)
j33 = a(33) + 1
If j33 <= 0 Or j33 > 4 Then GoTo 330
If b(9, j33) = 0 Then b(9, j33) = j33: c(9, 1) = j33 Else GoTo 330

For j32 = 2 To 2                                                    'a(32)
If b(8, j32) = 0 Then b(8, j32) = j32: c(8, 4) = j32 Else GoTo 320
a(32) = j32 - 1
For j31 = 3 To 3                                                    'a(31)
If b(8, j31) = 0 Then b(8, j31) = j31: c(8, 3) = j31 Else GoTo 310
a(31) = j31 - 1
For j30 = 2 To 2                                                    'a(30)
If b(7, j30) = 0 Then b(7, j30) = j30: c(7, 4) = j30 Else GoTo 300
a(30) = j30 - 1
For j29 = 3 To 3                                                    'a(29)
If b(7, j29) = 0 Then b(7, j29) = j29: c(7, 3) = j29 Else GoTo 290
a(29) = j29 - 1
For j28 = 1 To 1                                                    'a(28)
If b(6, j28) = 0 Then b(6, j28) = j28: c(6, 4) = j28 Else GoTo 280
a(28) = j28 - 1
For j27 = 2 To 2                                                    'a(27)
If b(6, j27) = 0 Then b(6, j27) = j27: c(6, 3) = j27 Else GoTo 270
a(27) = j27 - 1
For j26 = 3 To 3                                                    'a(26)
If b(5, j26) = 0 Then b(5, j26) = j26: c(5, 4) = j26 Else GoTo 260
a(26) = j26 - 1
a(25) = 12 - a(26) - a(27) - a(28) - a(29) - a(30) - a(31) - a(32)
j25 = a(25) + 1
If j25 <= 0 Or j25 > 4 Then GoTo 250
If b(5, j25) = 0 Then b(5, j25) = j25: c(5, 3) = j25 Else GoTo 250

For j24 = 1 To 1                                                    'a(24)
If b(8, j24) = 0 Then b(8, j24) = j24: c(8, 2) = j24 Else GoTo 240
a(24) = j24 - 1
a(23) = 6 - a(24) - a(31) - a(32)
j23 = a(23) + 1
If j23 <= 0 Or j23 > 4 Then GoTo 230
If b(8, j23) = 0 Then b(8, j23) = j23: c(8, 1) = j23 Else GoTo 230
For j22 = 4 To 4                                                    'a(22)
If b(7, j22) = 0 Then b(7, j22) = j22: c(7, 2) = j22 Else GoTo 220
a(22) = j22 - 1
a(21) = 6 - a(22) - a(29) - a(30)
j21 = a(21) + 1
If j21 <= 0 Or j21 > 4 Then GoTo 210
If b(7, j21) = 0 Then b(7, j21) = j21: c(7, 1) = j21 Else GoTo 210
For j20 = 4 To 4                                                    'a(20)
If b(6, j20) = 0 Then b(6, j20) = j20: c(6, 2) = j20 Else GoTo 200
a(20) = j20 - 1
a(19) = 6 - a(20) - a(27) - a(28)
j19 = a(19) + 1
If j19 <= 0 Or j19 > 4 Then GoTo 190
If b(6, j19) = 0 Then b(6, j19) = j19: c(6, 1) = j19 Else GoTo 190
For j18 = 2 To 2                                                    'a(18)
If b(5, j18) = 0 Then b(5, j18) = j18: c(5, 2) = j18 Else GoTo 180
a(18) = j18 - 1
a(17) = 6 - a(18) - a(25) - a(26)
j17 = a(17) + 1
If j17 <= 0 Or j17 > 4 Then GoTo 170
If b(5, j17) = 0 Then b(5, j17) = j17: c(5, 1) = j17 Else GoTo 170

For j16 = 1 To 4                                                    'a(16)
If b(4, j16) = 0 Then b(4, j16) = j16: c(4, 4) = j16 Else GoTo 160
a(16) = j16 - 1
a(15) = 18 + a(16) - a(22) + a(24) - a(29) + a(32) - a(35) - 2 * a(36) - a(39) - 2 * a(43) - a(44) - a(47) - a(50) - a(55) - a(57) - a(63)
j15 = a(15) + 1: If j15 <= 0 Or j15 > 4 Then GoTo 150
If b(4, j15) = 0 Then b(4, j15) = j15: c(4, 3) = j15 Else GoTo 150

a(8) = -12 - a(16) - a(24) - a(32) + a(35) + a(36) + a(39) + a(43) + a(44) + a(47) + a(51) + a(52) + a(55) + a(59) + a(60) + a(63)
j8 = a(8) + 1: If j8 <= 0 Or j8 > 4 Then GoTo 148
If b(4, j8) = 0 Then b(4, j8) = j8: c(4, 2) = j8 Else GoTo 148

a(7) = -18 - a(16) + a(22) + a(29) + a(35) + 2 * a(36) + 2 * a(43) + a(44) + a(50) + a(51) + a(52) + a(57) + a(59) + a(60)
j7 = a(7) + 1: If j7 <= 0 Or j7 > 4 Then GoTo 146
If b(4, j7) = 0 Then b(4, j7) = j7: c(4, 1) = j7 Else GoTo 146

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

a(6) = 12 - a(14) - a(22) - a(30) - a(38) - a(46) - a(54) - a(62)
j6 = a(6) + 1: If j6 <= 0 Or j6 > 4 Then GoTo 138
If b(3, j6) = 0 Then b(3, j6) = j6: c(3, 2) = j6 Else GoTo 138

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

a(5) = -6 - a(13) + a(22) + a(30) + a(38) + a(46) + a(54) + a(62)
If a(5) < 0 Or a(5) > 3 Then GoTo 125
j5 = a(5) + 1: If b(3, j5) = 0 Then b(3, j5) = j5: c(3, 1) = j5 Else GoTo 125

For j12 = 1 To 4                                                    'a(12)
If b(2, j12) = 0 Then b(2, j12) = j12: c(2, 4) = j12 Else GoTo 120
a(12) = j12 - 1

a(4) = 12 - a(12) - a(20) - a(28) - a(36) - a(44) - a(52) - a(60)
If a(4) < 0 Or a(4) > 3 Then GoTo 115
j4 = a(4) + 1: If b(2, j4) = 0 Then b(2, j4) = j4: c(2, 2) = j4 Else GoTo 115

For j11 = 1 To 4                                                    'a(11)
If b(2, j11) = 0 Then b(2, j11) = j11: c(2, 3) = j11 Else GoTo 110
a(11) = j11 - 1

a(10) = 12-(a(11)+a(12)+a(13)+a(14)+a(15)+a(16)+a(18)-a(20)+a(26)-a(27)+a(34)+a(37)+a(42)+a(46)+a(50)+a(55)+a(58)+a(64))/2
If a(10) < 0 Or a(10) > 3 Or Int(a(10)) <> a(10) Then GoTo 100
j10 = a(10) + 1: If b(1, j10) = 0 Then b(1, j10) = j10: c(1, 4) = j10 Else GoTo 100

a(9) = 12 - a(10) - a(11) - a(12) - a(13) - a(14) - a(15) - a(16)
If a(9) < 0 Or a(9) > 3 Then GoTo 90
j9 = a(9) + 1: If b(1, j9) = 0 Then b(1, j9) = j9: c(1, 3) = j9 Else GoTo 90

a(3) = 6 - a(11) + a(20) + a(28) - a(35) - a(43) - a(51) - a(59)
If a(3) < 0 Or a(3) > 3 Then GoTo 85
j3 = a(3) + 1: If b(2, j3) = 0 Then b(2, j3) = j3: c(2, 1) = j3 Else GoTo 85

a(2) = 12 - a(10) - a(18) - a(26) - a(34) - a(42) - a(50) - a(58)
If a(2) < 0 Or a(2) > 3 Then GoTo 80
j2 = a(2) + 1: If b(1, j2) = 0 Then b(1, j2) = j2: c(1, 2) = j2 Else GoTo 80

a(1) = -6 - a(9) + a(18) + a(26) + a(34) + a(42) + a(50) + a(58)
If a(1) < 0 Or a(1) > 3 Then GoTo 75
j1 = a(1) + 1: If b(1, j1) = 0 Then b(1, j1) = j1: c(1, 1) = j1 Else GoTo 75

'                           n9 = n9 + 1: GoSub 645 'Print results (selected numbers)
n9 = n9 + 1: GoSub 650 'Print results (Medjig Squares)
'                           n9 = n9 + 1: GoSub 700 'Calculate and print Magic Square

b(1, c(1, 1)) = 0: c(1, 1) = 0
75  b(1, c(1, 2)) = 0: c(1, 2) = 0
80  b(2, c(2, 1)) = 0: c(2, 1) = 0
85  b(1, c(1, 3)) = 0: c(1, 3) = 0
90  b(1, c(1, 4)) = 0: c(1, 4) = 0
100 b(2, c(2, 3)) = 0: c(2, 3) = 0
110 Next j11
b(2, c(2, 2)) = 0: c(2, 2) = 0
115 b(2, c(2, 4)) = 0: c(2, 4) = 0
120 Next j12
b(3, c(3, 1)) = 0: c(3, 1) = 0
125 b(3, c(3, 3)) = 0: c(3, 3) = 0
130 Next j13
b(3, c(3, 2)) = 0: c(3, 2) = 0
138 b(3, c(3, 4)) = 0: c(3, 4) = 0
140 Next j14

b(4, c(4, 1)) = 0: c(4, 1) = 0
146 b(4, c(4, 2)) = 0: c(4, 2) = 0
148 b(4, c(4, 3)) = 0: c(4, 3) = 0
150 b(4, c(4, 4)) = 0: c(4, 4) = 0
160 Next j16

b(5, c(5, 1)) = 0: c(5, 1) = 0
170 b(5, c(5, 2)) = 0: c(5, 2) = 0
180 Next j18
b(6, c(6, 1)) = 0: c(6, 1) = 0
190 b(6, c(6, 2)) = 0: c(6, 2) = 0
200 Next j20
b(7, c(7, 1)) = 0: c(7, 1) = 0
210 b(7, c(7, 2)) = 0: c(7, 2) = 0
220 Next j22
b(8, c(8, 1)) = 0: c(8, 1) = 0
230 b(8, c(8, 2)) = 0: c(8, 2) = 0
240 Next j24

b(5, c(5, 3)) = 0: c(5, 3) = 0
250 b(5, c(5, 4)) = 0: c(5, 4) = 0
260 Next j26
b(6, c(6, 3)) = 0: c(6, 3) = 0
270 Next j27
b(6, c(6, 4)) = 0: c(6, 4) = 0
280 Next j28
b(7, c(7, 3)) = 0: c(7, 3) = 0
290 Next j29
b(7, c(7, 4)) = 0: c(7, 4) = 0
300 Next j30
b(8, c(8, 3)) = 0: c(8, 3) = 0
310 Next j31
b(8, c(8, 4)) = 0: c(8, 4) = 0
320 Next j32

b(9, c(9, 1)) = 0: c(9, 1) = 0
330 b(9, c(9, 2)) = 0: c(9, 2) = 0
340 Next j34
b(10, c(10, 1)) = 0: c(10, 1) = 0
350 b(10, c(10, 2)) = 0: c(10, 2) = 0
360 Next j36
b(11, c(11, 1)) = 0: c(11, 1) = 0
370 b(11, c(11, 2)) = 0: c(11, 2) = 0
380 Next j38
b(12, c(12, 1)) = 0: c(12, 1) = 0
390 b(12, c(12, 2)) = 0: c(12, 2) = 0
400 Next j40

b(9, c(9, 3)) = 0: c(9, 3) = 0
410 b(9, c(9, 4)) = 0: c(9, 4) = 0
420 Next j42
b(10, c(10, 3)) = 0: c(10, 3) = 0
430 Next j43
b(10, c(10, 4)) = 0: c(10, 4) = 0
440 Next j44
b(11, c(11, 3)) = 0: c(11, 3) = 0
450 Next j45
b(11, c(11, 4)) = 0: c(11, 4) = 0
460 Next j46
b(12, c(12, 3)) = 0: c(12, 3) = 0
470 Next j47
b(12, c(12, 4)) = 0: c(12, 4) = 0
480 Next j48

b(13, c(13, 1)) = 0: c(13, 1) = 0
490 b(13, c(13, 2)) = 0: c(13, 2) = 0
500 Next j50
b(14, c(14, 1)) = 0: c(14, 1) = 0
510 b(14, c(14, 2)) = 0: c(14, 2) = 0
520 Next j52
b(15, c(15, 1)) = 0: c(15, 1) = 0
530 b(15, c(15, 2)) = 0: c(15, 2) = 0
540 Next j54
b(16, c(16, 1)) = 0: c(16, 1) = 0
550 b(16, c(16, 2)) = 0: c(16, 2) = 0
560 Next j56

b(13, c(13, 3)) = 0: c(13, 3) = 0
570 b(13, c(13, 4)) = 0: c(13, 4) = 0
580 Next j58
b(14, c(14, 3)) = 0: c(14, 3) = 0
590 Next j59
b(14, c(14, 4)) = 0: c(14, 4) = 0
600 Next j60
b(15, c(15, 3)) = 0: c(15, 3) = 0
610 Next j61
b(15, c(15, 4)) = 0: c(15, 4) = 0
620 Next j62
b(16, c(16, 3)) = 0: c(16, 3) = 0
630 Next j63
b(16, c(16, 4)) = 0: c(16, 4) = 0
640 Next j64

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

End

Return

'   Print results (selected numbers)

645 For i1 = 1 To 64
Cells(n9, i1).Value = a(i1)
Next i1

Return

'   Print results (squares)

650 n2 = n2 + 1
If n2 = 5 Then
n2 = 1: k1 = k1 + 9: k2 = 0
Else
If n9 > 1 Then k2 = k2 + 9
End If

Cells(k1 + 1, k2 + 1).Select

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

Return

'   Calculate and print Magic Square

700 c1(1) = b1(1) + 16 * a(1): c1(2) = b1(1) + 16 * a(2): c1(3) = b1(2) + 16 * a(3): c1(4) = b1(2) + 16 * a(4)
c1(5) = b1(3) + 16 * a(5): c1(6) = b1(3) + 16 * a(6): c1(7) = b1(4) + 16 * a(7): c1(8) = b1(4) + 16 * a(8)

c1(9) = b1(1) + 16 * a(9): c1(10) = b1(1) + 16 * a(10): c1(11) = b1(2) + 16 * a(11): c1(12) = b1(2) + 16 * a(12)
c1(13) = b1(3) + 16 * a(13): c1(14) = b1(3) + 16 * a(14): c1(15) = b1(4) + 16 * a(15): c1(16) = b1(4) + 16 * a(16)

c1(17) = b1(5) + 16 * a(17): c1(18) = b1(5) + 16 * a(18): c1(19) = b1(6) + 16 * a(19): c1(20) = b1(6) + 16 * a(20)
c1(21) = b1(7) + 16 * a(21): c1(22) = b1(7) + 16 * a(22): c1(23) = b1(8) + 16 * a(23): c1(24) = b1(8) + 16 * a(24)

c1(25) = b1(5) + 16 * a(25): c1(26) = b1(5) + 16 * a(26): c1(27) = b1(6) + 16 * a(27): c1(28) = b1(6) + 16 * a(28)
c1(29) = b1(7) + 16 * a(29): c1(30) = b1(7) + 16 * a(30): c1(31) = b1(8) + 16 * a(31): c1(32) = b1(8) + 16 * a(32)

c1(33) = b1(9) + 16 * a(33): c1(34) = b1(9) + 16 * a(34): c1(35) = b1(10) + 16 * a(35): c1(36) = b1(10) + 16 * a(36)
c1(37) = b1(11) + 16 * a(37): c1(38) = b1(11) + 16 * a(38): c1(39) = b1(12) + 16 * a(39): c1(40) = b1(12) + 16 * a(40)

c1(41) = b1(9) + 16 * a(41): c1(42) = b1(9) + 16 * a(42): c1(43) = b1(10) + 16 * a(43): c1(44) = b1(10) + 16 * a(44)
c1(45) = b1(11) + 16 * a(45): c1(46) = b1(11) + 16 * a(46): c1(47) = b1(12) + 16 * a(47): c1(48) = b1(12) + 16 * a(48)

c1(49) = b1(13) + 16 * a(49): c1(50) = b1(13) + 16 * a(50): c1(51) = b1(14) + 16 * a(51): c1(52) = b1(14) + 16 * a(52)
c1(53) = b1(15) + 16 * a(53): c1(54) = b1(15) + 16 * a(54): c1(55) = b1(16) + 16 * a(55): c1(56) = b1(16) + 16 * a(56)

c1(57) = b1(13) + 16 * a(57): c1(58) = b1(13) + 16 * a(58): c1(59) = b1(14) + 16 * a(59): c1(60) = b1(14) + 16 * a(60)
c1(61) = b1(15) + 16 * a(61): c1(62) = b1(15) + 16 * a(62): c1(63) = b1(16) + 16 * a(63): c1(64) = b1(16) + 16 * a(64)

n2 = n2 + 1
If n2 = 5 Then
n2 = 1: k1 = k1 + 9: k2 = 0
Else
If n9 > 1 Then k2 = k2 + 9
End If

Cells(k1 + 1, k2 + 1).Select

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

Return

End Sub
```