Sub Echiquier()
Const nb_cases As Integer = 8 'Echiquier de 8x8 cellules
Dim lig As Integer, col As Integer, nbr As Long ' => ajout des variables
Dim i As Integer, j As Integer
Application.ScreenUpdating = False
Application.Goto Range("c3")
'Décalage (lignes) à partir de la première cellule = n° de ligne de la cellule active - 1
lig = ActiveCell.Row - 1
'Décalage (colonnes) à partir de la première cellule = n° de colonne de la cellule active - 1
col = ActiveCell.Column - 1
'Dimensions des cellules
With Range("b:b, k:k"): .ColumnWidth = 2.8: .RowHeight = 19: End With
With Range("c3:j10"): .ColumnWidth = 7: .RowHeight = 37.5: .BorderAround Weight:=xlMedium: End With
'Bordures extérieures
With Range("b2:k11"): .BorderAround Weight:=xlThick: .Interior.Color = RGB(143, 80, 53): End With
'Numéros et lettres des cases
For i = 3 To 10
nbr = nbr + 1
Range("k" & i) = nbr
Range("k" & i).HorizontalAlignment = xlCenter
Range("k" & i).VerticalAlignment = xlCenter
Range("k" & i).Font.Bold = True
Range("k" & i).Font.ColorIndex = 2
Next
With Range("c2:j2"): .Value = [{"A", "B", "C", "D", "E", "F", "G", "H"}]: .HorizontalAlignment = xlCenter: _
.VerticalAlignment = xlCenter: .Font.Bold = True: .Font.ColorIndex = 2: End With
'Coloriage des cellules
For l = 1 To nb_cases 'N° ligne
For c = 1 To nb_cases 'N° colonne
If (l + c) Mod 2 = 0 Then
'Cells(n° de ligne + décalage lignes, n° de colonne + décalage colonnes)...
Cells(l + lig, c + col).Interior.Color = RGB(216, 176, 136) 'Brun clair
Else
Cells(l + lig, c + col).Interior.Color = RGB(128, 128, 128) 'Gris clair
End If
Next
Next
'Mise en place des pièces blanches
'Les Tourres
Range("c3") = ChrW(&H2656): Range("j3") = ChrW(&H2656)
'Les Cavaliers
Range("d3") = ChrW(&H2658): Range("i3") = ChrW(&H2658)
'Les Fous
Range("e3") = ChrW(&H2657): Range("h3") = ChrW(&H2657)
'La Reine 'Le Roi
Range("f3") = ChrW(&H2655): Range("g3") = ChrW(&H2654)
'Les Pions
With ActiveSheet.Range("c4:j4"): Range("c4:j4") = ChrW(&H2659): .Font.Name = "Arial": .Font.Size = 28: _
.Font.Bold = True: .HorizontalAlignment = xlCenter: .VerticalAlignment = xlCenter: .Font.ColorIndex = 2: End With
With ActiveSheet.Range("c3:j3"): .Font.Name = "Arial": .Font.Size = 28: .Font.Bold = True: _
.HorizontalAlignment = xlCenter: .VerticalAlignment = xlCenter: .Font.ColorIndex = 2: End With
'Mise en place des pièces noires
'Les Tourres
Range("c10") = ChrW(&H265C): Range("j10") = ChrW(&H265C)
'Les Cavaliers
Range("d10") = ChrW(&H265E): Range("i10") = ChrW(&H265E)
'Les Fous
Range("e10") = ChrW(&H265D): Range("h10") = ChrW(&H265D)
'La Reine 'Le Roi
Range("f10") = ChrW(&H265B): Range("g10") = ChrW(&H265A)
'Les Pions
With ActiveSheet.Range("c9:j9"): Range("c9:j9") = ChrW(&H265F): .Font.Name = "Arial": .Font.Size = 28: _
.Font.Bold = True: .HorizontalAlignment = xlCenter: .VerticalAlignment = xlCenter: .Font.ColorIndex = 0: End With
With ActiveSheet.Range("c10:j10"): .Font.Name = "Arial": .Font.Size = 28: .Font.Bold = True: _
.HorizontalAlignment = xlCenter: .VerticalAlignment = xlCenter: .Font.ColorIndex = 0: End With
Application.Goto Range("m1")
End Sub