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 34 35 36 37 38 39 40 41 42 43 44
| Sub Bt_Enregistrer9_Click()
'Champ nom de l'agrégat vide
If Uf_AgregatsAjout.Tb_Nouvelagregat9 = "" Then
MsgBox "Merci d'indiquer le nom du nouvel agrégat.", vbInformation
Else
'Placement sur la feuille "Agrégats"
Worksheets("Agrégats").Activate
Range("a1").Select
Do
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Value = "" Or ActiveCell.Value = Uf_AgregatsAjout.Tb_Nouvelagregat9.Value
If ActiveCell.Value = Uf_AgregatsAjout.Tb_Nouvelagregat9.Value Then
MsgBox "Cet agrégat existe déjà.", vbInformation
Else
'On se positionne sur la dernière ligne du tableau pour insérer une ligne
ActiveCell.Offset(-1, 0).Select
'Insertion d'une ligne lors de l'enregistrement
ActiveCell.EntireRow.Insert Shift:=xlDown
ActiveCell.Value = Uf_AgregatsAjout.Tb_Nouvelagregat9.Value
'Message de confirmation d'enregistrement
MsgBox "L'agrégat " & Uf_AgregatsAjout.Tb_Nouvelagregat9.Value & " a été ajouté.", vbInformation
Text1 = Uf_AgregatsAjout.Tb_Nouvelagregat9.Value
'Retour à Uf_Agregats
Unload Uf_AgregatsAjout
Uf_Agregats.Cb_Agregat7.Value = Text1
Uf_Agregats.Show
End If
End If
End Sub |
Partager