bonsoir,
je créer automatiquement des options buttons dans des frames, le probleme est que l'on ne peut pas cocher plusieurs options buttons dans le meme frame mais on peut par exemple cliquer sur le bouton option 1 du frame 1 et sur le bouton option 1 du frame 2 or je ne veux que l'on puisse faire je veux que l'on puisse cliquer que sur un seul bouton d'option dans mon formulaire quelqu'un a t'il une idee voici mon code
private sub userform_initialize()
460 J = 0
'*****************************************liste des activités**************************************
'compter le nombre d'activité=j
470 For i = 2 To 30
480 If ThisWorkbook.Worksheets("Act_tach_def").Range("A" & i + 1) <> ThisWorkbook.Worksheets("Act_tach_def").Range("A" & i) Then
490 J = J + 1
500 End If
510 Next i
'tri les activités
520 Range("A2:A34").Select
530 ActiveWorkbook.Worksheets("Act_tach_def").Sort.SortFields.Clear
540 ActiveWorkbook.Worksheets("Act_tach_def").Sort.SortFields.Add Key:=Range("A2" _
), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
550 With ActiveWorkbook.Worksheets("Act_tach_def").Sort
560 .SetRange Range("A2:C33")
570 .Header = xlNo
580 .MatchCase = False
590 .Orientation = xlTopToBottom
600 .SortMethod = xlPinYin
610 .Apply
620 End With
630 Set f = ThisWorkbook.Sheets("programmes activités")
640 Set f2 = ThisWorkbook.Sheets("Act_tach_def")
650 LIGNE = 2
660 nbCol = f.[A1].CurrentRegion.Columns.Count
670 x = 11
680 y = 15
'crée les frames
690 For i = 1 To J
700 retour = Me.Controls.Add("Forms.frame.1", "frame" & i, True)
710 Me("frame" & i).Top = 200
720 Me("frame" & i).Left = Z
730 Me("frame" & i).Caption = ThisWorkbook.Worksheets("Act_tach_def").Range("F" & i + 1).Value
740 Me("frame" & i).Width = 180
750 Me("frame" & i).Height = 250
760 Me("frame" & i).BorderStyle = fmBorderStyleSingle
770 If i = 1 Then
780 Me("frame" & i).ForeColor = vbBlue
790 Me("frame" & i).BorderColor = vbBlue
800 ElseIf i = 2 Then
810 Me("frame" & i).ForeColor = RGB(0, 0, 100)
820 Me("frame" & i).BorderColor = RGB(0, 0, 100)
830 ElseIf i = 3 Then
840 Me("frame" & i).ForeColor = vbRed
850 Me("frame" & i).BorderColor = vbRed
860 ElseIf i = 4 Then
870 Me("frame" & i).ForeColor = vbMagenta
880 Me("frame" & i).BorderColor = vbMagenta
890 ElseIf i = 5 Then
900 Me("frame" & i).ForeColor = RGB(128, 0, 255)
910 Me("frame" & i).ForeColor = RGB(128, 0, 255)
920 ElseIf i = 6 Then
930 Me("frame" & i).ForeColor = vbBlack
940 Me("frame" & i).BorderColor = vbBlack
950 End If
960 Z = Z + 180
970 Next i
'************************************************essai*******************************************
'crée les boutons à l'interieur des frames
Dim Obj As Control
980 n = 2
990 Set Collect = New Collection
1000 For i = 1 To J
1010 For k = 1 To ThisWorkbook.Worksheets("Act_tach_def").Range("G" & i + 1).Value
'boucle pour la création des CheckBox
1020 Set Obj = Me.Controls("frame" & i).Controls.Add("forms.optionbutton.1")
1030 With Obj
1040 .Name = "opt" & k
1050 .Object.Caption = ThisWorkbook.Worksheets("Act_tach_def").Range("B" & n).Value
1060 .Left = 11
1070 .Top = 30 * (k) + 10
1080 .Width = 150
1090 .Height = 50
1100 .Object.AutoSize = True
'ajoute la définition sous forme d'info bulle (à modifier le format)
1110 .ControlTipText = ThisWorkbook.Worksheets("Act_tach_def").Range("C" & n).Value
'.Tag = ThisWorkbook.Worksheets("Act_tach_def").Range("C" & n).Value
'passe à la ligne suivante
n = n + 1
1130 End With
1140 Next k
1150 Next i
1160 ThisWorkbook.Sheets("Act_tach_def").Visible = False
1170 ThisWorkbook.Sheets("programmes activités").Visible = False
1180 Application.Calculation = xlCalculationAutomatic
1190 Application.ScreenUpdating = True
end sub
merci pour votre aide
je créer automatiquement des options buttons dans des frames, le probleme est que l'on ne peut pas cocher plusieurs options buttons dans le meme frame mais on peut par exemple cliquer sur le bouton option 1 du frame 1 et sur le bouton option 1 du frame 2 or je ne veux que l'on puisse faire je veux que l'on puisse cliquer que sur un seul bouton d'option dans mon formulaire quelqu'un a t'il une idee voici mon code
private sub userform_initialize()
460 J = 0
'*****************************************liste des activités**************************************
'compter le nombre d'activité=j
470 For i = 2 To 30
480 If ThisWorkbook.Worksheets("Act_tach_def").Range("A" & i + 1) <> ThisWorkbook.Worksheets("Act_tach_def").Range("A" & i) Then
490 J = J + 1
500 End If
510 Next i
'tri les activités
520 Range("A2:A34").Select
530 ActiveWorkbook.Worksheets("Act_tach_def").Sort.SortFields.Clear
540 ActiveWorkbook.Worksheets("Act_tach_def").Sort.SortFields.Add Key:=Range("A2" _
), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
550 With ActiveWorkbook.Worksheets("Act_tach_def").Sort
560 .SetRange Range("A2:C33")
570 .Header = xlNo
580 .MatchCase = False
590 .Orientation = xlTopToBottom
600 .SortMethod = xlPinYin
610 .Apply
620 End With
630 Set f = ThisWorkbook.Sheets("programmes activités")
640 Set f2 = ThisWorkbook.Sheets("Act_tach_def")
650 LIGNE = 2
660 nbCol = f.[A1].CurrentRegion.Columns.Count
670 x = 11
680 y = 15
'crée les frames
690 For i = 1 To J
700 retour = Me.Controls.Add("Forms.frame.1", "frame" & i, True)
710 Me("frame" & i).Top = 200
720 Me("frame" & i).Left = Z
730 Me("frame" & i).Caption = ThisWorkbook.Worksheets("Act_tach_def").Range("F" & i + 1).Value
740 Me("frame" & i).Width = 180
750 Me("frame" & i).Height = 250
760 Me("frame" & i).BorderStyle = fmBorderStyleSingle
770 If i = 1 Then
780 Me("frame" & i).ForeColor = vbBlue
790 Me("frame" & i).BorderColor = vbBlue
800 ElseIf i = 2 Then
810 Me("frame" & i).ForeColor = RGB(0, 0, 100)
820 Me("frame" & i).BorderColor = RGB(0, 0, 100)
830 ElseIf i = 3 Then
840 Me("frame" & i).ForeColor = vbRed
850 Me("frame" & i).BorderColor = vbRed
860 ElseIf i = 4 Then
870 Me("frame" & i).ForeColor = vbMagenta
880 Me("frame" & i).BorderColor = vbMagenta
890 ElseIf i = 5 Then
900 Me("frame" & i).ForeColor = RGB(128, 0, 255)
910 Me("frame" & i).ForeColor = RGB(128, 0, 255)
920 ElseIf i = 6 Then
930 Me("frame" & i).ForeColor = vbBlack
940 Me("frame" & i).BorderColor = vbBlack
950 End If
960 Z = Z + 180
970 Next i
'************************************************essai*******************************************
'crée les boutons à l'interieur des frames
Dim Obj As Control
980 n = 2
990 Set Collect = New Collection
1000 For i = 1 To J
1010 For k = 1 To ThisWorkbook.Worksheets("Act_tach_def").Range("G" & i + 1).Value
'boucle pour la création des CheckBox
1020 Set Obj = Me.Controls("frame" & i).Controls.Add("forms.optionbutton.1")
1030 With Obj
1040 .Name = "opt" & k
1050 .Object.Caption = ThisWorkbook.Worksheets("Act_tach_def").Range("B" & n).Value
1060 .Left = 11
1070 .Top = 30 * (k) + 10
1080 .Width = 150
1090 .Height = 50
1100 .Object.AutoSize = True
'ajoute la définition sous forme d'info bulle (à modifier le format)
1110 .ControlTipText = ThisWorkbook.Worksheets("Act_tach_def").Range("C" & n).Value
'.Tag = ThisWorkbook.Worksheets("Act_tach_def").Range("C" & n).Value
'passe à la ligne suivante
n = n + 1
1130 End With
1140 Next k
1150 Next i
1160 ThisWorkbook.Sheets("Act_tach_def").Visible = False
1170 ThisWorkbook.Sheets("programmes activités").Visible = False
1180 Application.Calculation = xlCalculationAutomatic
1190 Application.ScreenUpdating = True
end sub
merci pour votre aide