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 45 46 47 48 49 50 51 52 53 54
| Private Sub CommandButton_Ajouter_Click()
'Coloration des Labels en noir
Label_TypedeFichier.ForeColor = RGB(0, 0, 0)
Label_Format.ForeColor = RGB(0, 0, 0)
Label_Ouvrages.ForeColor = RGB(0, 0, 0)
'Contrôles de contenu
If TextBox_Format.Value = "" Then 'SI pas de "nom" ...
Label_Format.ForeColor = RGB(255, 0, 0) 'Label "nom" en rouge
ElseIf TextBox_Ouvrages.Value = "" Then
Label_Ouvrages.ForeColor = RGB(255, 0, 0)
Else
'Si le formulaire est complet, on insère les valeurs sur la feuille
Dim no_ligne As Integer, TypedeFichier As String
'Choix de Type de Fichier
For Each bouton_TypedeFichier In Frame_TypedeFichier.Controls
If bouton_TypedeFichier.Value Then
TypedeFichier = bouton_TypedeFichier.Caption
End If
Next
'no_ligne = N° de ligne de la dernière cellule non vide de la colonne +1
no_ligne = Range("A65536").End(xlUp).Row + 1
'Insertion des valeurs sur la feuille
Cells(no_ligne, 1) = TypedeFichier
Cells(no_ligne, 2) = TextBox_Format.Value
Cells(no_ligne, 3) = TextBox_Ouvrages.Value
Cells(no_ligne, 4) = TextBox_Mode_Constructif.Value
Cells(no_ligne, 5) = TextBox_N°_Document.Value
Cells(no_ligne, 6) = TextBox_Materiel.Value
Cells(no_ligne, 7) = TextBox_Engins.Value
Cells(no_ligne, 8) = TextBox_Element_de_securite.Value
Cells(no_ligne, 9) = TextBox_Famille.Value
Cells(no_ligne, 10) = TextBox_Chantier.Value
Cells(no_ligne, 11) = TextBox_Liens_PDF.Value
Cells(no_ligne, 12) = TextBox_Liens_DWG.Value
'Après insertion, on remet les valeurs initiales
OptionButton1.Value = True
TextBox_Format.Value = ""
TextBox_Ouvrages.Value = ""
TextBox_Mode_Constructif.Value = ""
TextBox_N°_Document.Value = ""
TextBox_Materiel.Value = ""
TextBox_Engins.Value = ""
TextBox_Element_de_securite.Value = ""
TextBox_Famille.Value = ""
TextBox_Chantier.Value = ""
TextBox_Liens_PDF.Value = ""
TextBox_Liens_DWG.Value = ""
End If
End Sub |
Partager