Re : Copie de macro
Et voici le code du Userform :
Private Sub ComboBoxCycle_Change()
ComboBoxGroupe.Clear
ComboBoxDetail.Clear
Dim Ligne, Competence, i As Integer
Ligne = FeuilCompetence.Cells(ComboBoxCycle.ListIndex + 1, 2).Value
Do
ComboBoxGroupe.AddItem FeuilCompetence.Cells(Ligne, 2).Value
Ligne = Ligne + FeuilCompetence.Cells(Ligne + 1, 1).Value + 1
Loop While (FeuilCompetence.Cells(Ligne, 1).Value <> "")
Ligne = FeuilCompetence.Cells(ComboBoxCycle.ListIndex + 1, 2).Value + 1
Competence = FeuilCompetence.Cells(Ligne, 1).Value - 1
For i = 0 To Competence
ComboBoxDetail.AddItem FeuilCompetence.Cells(Ligne + i, 3).Value
Next
ComboBoxGroupe.Value = FeuilCompetence.Cells(FeuilCompetence.Cells(ComboBoxCycle.ListIndex + 1, 2).Value, 2).Value
ComboBoxDetail.Value = FeuilCompetence.Cells(FeuilCompetence.Cells(ComboBoxCycle.ListIndex + 1, 2).Value + 1, 3).Value
End Sub
Private Sub ComboBoxGroupe_Change()
Dim i As Integer
ComboBoxDetail.Clear
Ligne = FeuilCompetence.Cells(ComboBoxCycle.ListIndex + 1, 2).Value + 1
For i = 1 To ComboBoxGroupe.ListIndex
Ligne = Ligne + FeuilCompetence.Cells(Ligne, 1).Value + 1
Next
ComboBoxDetail.Value = FeuilCompetence.Cells(Ligne, 3).Value
Competence = FeuilCompetence.Cells(Ligne, 1).Value - 1
For i = 0 To Competence
ComboBoxDetail.AddItem FeuilCompetence.Cells(Ligne + i, 3).Value
Next
End Sub
Private Sub CommandButton1_Click()
ActiveCell.Value = ComboBoxDetail.Value
ActiveCell.Offset(1).Select
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub CommandButton3_Click()
ActiveCell.Value = ComboBoxGroupe.Value
ActiveCell.Offset(1).Select
End Sub
Private Sub UserForm_Initialize()
Dim Ligne, Competence, i As Integer
Ligne = 1
Do
ComboBoxCycle.AddItem FeuilCompetence.Cells(Ligne, 1).Value
Ligne = Ligne + 1
Loop While (FeuilCompetence.Cells(Ligne, 1).Value <> "")
Ligne = FeuilCompetence.Cells(1, 2)
Do
ComboBoxGroupe.AddItem FeuilCompetence.Cells(Ligne, 2).Value
Ligne = Ligne + FeuilCompetence.Cells(Ligne + 1, 1).Value + 1
Loop While (FeuilCompetence.Cells(Ligne, 1).Value <> "")
Ligne = FeuilCompetence.Cells(1, 2).Value + 1
Competence = FeuilCompetence.Cells(Ligne, 1).Value - 1
For i = 0 To Competence
ComboBoxDetail.AddItem FeuilCompetence.Cells(Ligne + i, 3).Value
Next
ComboBoxCycle.Value = FeuilCompetence.Cells(1, 1).Value
ComboBoxGroupe.Value = FeuilCompetence.Cells(FeuilCompetence.Cells(1, 2).Value, 2).Value
ComboBoxDetail.Value = FeuilCompetence.Cells(FeuilCompetence.Cells(1, 2).Value + 1, 3).Value
Initialisation = 1
End Sub