1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
Function est_carree(plage As Range) As Boolean
Dim nbcol As Integer
Dim nblig As Integer
nbcol = plage.Columns.Count
nblig = plage.Rows.Count
est_carree = (nbcol = nblig)
End Function
Sub diago_perso()
Dim i As Integer
Dim j As Integer
Dim nbcol As Integer
Dim haut As Integer
Dim gauche As Integer
Dim kase As Range
nbcol = Selection.Rows.Count
MsgBox ("nbcol: " & nbcol)
kase = Selection.End(xlTop).End(xlToLeft).Select
haut = kase.Row
MsgBox ("haut: " & haut)
gauche = Selection.End(xlToLeft)
If (est_carree(Selection) = True) Then
For i = gauche To nbcol
For j = haut To nbcol
Range(Cells(i, j)).Interior.ColorIndex = 3
j = j + nbcol
Next j
i = i + nbcol
Next i
Else
MsgBox ("La sélection n'est pas carrée")
End If
End Sub |