0% found this document useful (0 votes)
9 views3 pages

Codes Excel Vba

The document contains VBA code for a UserForm with three command buttons: one for saving data, one for searching data, and one for modifying existing data. The code checks for user input, confirms actions, and updates an Excel sheet accordingly. It includes message boxes for user prompts and feedback on operations performed.

Uploaded by

jose tembo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Codes Excel Vba

The document contains VBA code for a UserForm with three command buttons: one for saving data, one for searching data, and one for modifying existing data. The code checks for user input, confirms actions, and updates an Excel sheet accordingly. It includes message boxes for user prompts and feedback on operations performed.

Uploaded by

jose tembo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Private Sub CommandButton1_Click()

'BOUTON ENREGISTER

If ComboBox1.Value = "" Then

MsgBox "Veuillez renseigner l'opération svp"

Else

Dim ligne As Integer

If MsgBox("Confirmer l'ajout des données", vbYesNo, "Confirmation") = vbYes Then

ligne = Sheets("Feuil1").Select

ligne = Sheets("Feuil1").Range("A456541").End(xlUp).Row + 1

Cells(ligne, 1) = TextBox1.Value

Cells(ligne, 2) = ComboBox1.Value

Cells(ligne, 3) = TextBox2.Value

Cells(ligne, 4) = TextBox3.Value

Cells(ligne, 5) = TextBox4.Value

Unload UserForm1

UserForm1.Show

Else

End If

End If

End Sub

Private Sub CommandButton2_Click()

'BOUTON RECHERCHER

If Not ComboBox1.Value = "" Then

Dim no_ligne As Integer

no_ligne = ComboBox1.ListIndex + 2

TextBox1.Value = Cells(no_ligne, 1).Value


ComboBox1.Value = Cells(no_ligne, 2).Value

TextBox2.Value = Cells(no_ligne, 3).Value

TextBox3.Value = Cells(no_ligne, 4).Value

TextBox4.Value = Cells(no_ligne, 5).Value

Else

End If

End Sub

Private Sub CommandButton3_Click()

'BOUTON MODIFIER

Dim modif As Integer

If Not ComboBox1.Value = "" Then

Sheets("Feuil1").Select

modif = ComboBox1.ListIndex + 2

Cells(modif, 1) = TextBox1.Value

Cells(modif, 2) = ComboBox1.Value

Cells(modif, 3) = TextBox1.Value

Cells(modif, 4) = TextBox1.Value

Cells(modif, 5) = TextBox1.Value

MsgBox ("Modification réussie")

Else

MsgBox ("Modification echoué")

Exit Sub

End If

Unload UserForm1
UserForm1.Show 0

End Sub

You might also like