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
|
Sub bouton()
Dim i As Long
Dim j As Long
Dim nb_lign As Integer
Dim nb_col As Integer
Dim cbut As Object
Dim nb_lign_pass As Integer
Dim nb_col_pass As Integer
lign = 22
col = 2
nb_lign_pass = 10
nb_col_pass = 5
For i = 0 To nb_lign_pass - 2
For j = 1 To nb_col_pass - 1
If Cells(lign + i + 1, col) + Cells(lign, col + j) <= Cells(lign + nb_lign_pass - 1, col) + 1 Then
Set cbut = (ActiveWorkbook.ActiveSheet.OLEObjects.Add("Forms.toggleButton.1"))
'taille des boutons fassent la taille de la cellule
With cbut
.Top = Range(Cells(lign + i, col + j), Cells(lign + i, col + j)).Top
.Left = Range(Cells(lign + i, col + j), Cells(lign + i, col + j)).Left
.Width = Range(Cells(lign + i, col + j), Cells(lign + i, col + j)).Width
.Height = Range(Cells(lign + i, col + j), Cells(lign + i, col + j)).Height
.Name = "bouton" & i & j
.Object.Caption = 1.56284864238411 + i + j ' le bouton a la valeur du coeff de passage correspondant
End With
End If
Next
Next
End Sub |
Partager