You are on page 1of 5

EXO 1 :

Option Explicit

Dim FinLigne As Integer

Dim SelLigne As Integer

Sub Affichage(numero As Integer)

CmbCode.Value = Range("A" & numero).Value

TxtNom.Value = Range("B" & numero).Value

TxtProfession.Value = Range("C" & numero).Value

Label4.Caption = "N°" & (numero - 1) & "/" & (FinLigne - 1) 'CmbCode.count

End Sub

Private Sub CmbCode_Change()

SelLigne = CmbCode.ListIndex + 2

Affichage (SelLigne)

End Sub

Private Sub CmdQuitter_Click()

Dim rep As Integer

rep = MsgBox("Etes vous sûr de vouloir quitter ?", vbYesNo + vbCritical)

If rep = vbYes Then

Unload Me

End If

End Sub

Private Sub UserForm_Initialize()

Sheets("Données").Activate

'FinLigne = Sheets("Données").Range("A1").Rows.End(xlDown).Row

FinLigne = Sheets("Données").Range("A2000").Rows.End(xlUp).Row

Dim i As Integer
For i = 2 To FinLigne

CmbCode.AddItem Range("A" & i).Value

Next

SelLigne = 2

Affichage (SelLigne)

End Sub

EXO 2 :

Option Explicit

Dim FinLigne As Integer

Sub Affichage(i As Integer)

TxtPrenom.Value = Range("B" & i).Value

TxtAge.Value = Range("C" & i).Value

If Range("D" & i).Value = "Débutant" Then

OptDebutant.Value = True

Else

OptIntermediaire.Value = True

End If

End Sub

Sub Effacer()

TxtNom.Value = ""

TxtPrenom.Value = ""

TxtAge.Value = ""

OptDebutant.Value = False

OptIntermediaire.Value = False
End Sub

Private Sub BtnAfficher_Click()

Dim i As Integer

Dim trouve As Boolean

trouve = False

For i = 2 To FinLigne

If UCase(TxtNom.Value) = UCase(Range("A" & i).Value) Then

trouve = True

Exit For

End If

Next

If trouve = False Then

Effacer

MsgBox " Ce nom n'existe pas"

Else

Affichage (i)

End If

End Sub

Private Sub BtnAjouter_Click()

If BtnAjouter.Caption = "Ajouter" Then

Effacer

BtnAjouter.Caption = "Enregistrer"

Else

If TxtNom.Value = "" Or TxtPrenom.Value = "" Or TxtAge.Value = "" Or (OptDebutant = False And


OptIntermediaire = False) Then

MsgBox "erreur: Veuillez remplir toutes les zones"

Else

FinLigne = FinLigne + 1

Range("A" & FinLigne).Value = TxtNom.Value


Range("B" & FinLigne).Value = TxtPrenom.Value

Range("C" & FinLigne).Value = TxtAge.Value

If OptDebutant.Value = True Then

Range("D" & FinLigne).Value = "Débutant"

Else

Range("D" & FinLigne).Value = "Intermédiaire"

End If

BtnAjouter.Caption = "Ajouter"

End If

End If

End Sub

Private Sub UserForm_Initialize()

Sheets("Inscriptions").Activate

FinLigne = Sheets("Inscriptions").Range("A1").Rows.End(xlDown).Row

FinLigne = Sheets("Inscriptions").Range("A2000").Rows.End(xlUp).Row

End Sub

EXO 3 :

Option Explicit

Dim FinLigne As Integer

Dim FinColonne As Integer

Dim SelColonne As Integer

Private Sub ComboBox1_Change()

For SelColonne = 1 To FinColonne

If Sheets("Liste").Cells(2, SelColonne).Value = ComboBox1.Value Then

ListBox1.List = Sheets("Liste").Range(Cells(3, SelColonne), Cells(FinLigne, SelColonne)).Value

End If

Next

End Sub
Private Sub CommandButton1_Click()

Unload Me

End Sub

Private Sub UserForm_Initialize()

Sheets("Liste").Activate

FinLigne = Sheets("Liste").Range("A100").Rows.End(xlUp).Row

FinColonne = Sheets("Liste").Range("A1").End(xlToRight).Column

For SelColonne = 1 To FinColonne

ComboBox1.AddItem Sheets("Liste").Cells(2, SelColonne).Value

Next

End Sub

You might also like