J'ai utilisé ce formulaire pour gérer ma base de données mais les nombres que je rentre dans mes textboxs sont inexploitable, avec des formules .Message d'erreur :Le nombre dans cette cellule est au format texte ou précédé d'un apostrophe .
Merci d'avance pour vos réponse
Option Explicit
Dim Ws As Worksheet
'Pour le formulaire
Private Sub UserForm_Initialize()
Dim J As Long
Dim I As Integer
ComboBox2.ColumnCount = 1 'Pour la liste secteur
ComboBox2.List() = Array("T", "PC", "VT", "CNES", "M", "T,M", "") 'liste déroulante
Set Ws = Sheets("BASE DE DONNEES")
With Me.ComboBox1
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & J)
Next J
End With
For I = 1 To 9
Me.Controls("TextBox" & I).Visible = True
Next I
End Sub
'Pour la liste déroulante nom prenom
Private Sub ComboBox1_Change()
Dim Ligne As Long
Dim I As Integer
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
ComboBox2 = Ws.Cells(Ligne, "B")
For I = 1 To 9
Me.Controls("TextBox" & I) = Ws.Cells(Ligne, I + 2)
Next I
End Sub
Private Sub CommandButton4_Click()
'Pour le bouton Nouveau contact
Dim L As Integer
If MsgBox("Confirmez-vous l’insertion de ce nouveau contact ?", vbYesNo) = vbYes Then
L = Sheets("BASE DE DONNEES").Range("a65536").End(xlUp).Row + 1 'Pour placer le nouvel enregistrement à la première ligne de tableau non vide'
Range("A" & L).Value = ComboBox1
Range("B" & L).Value = ComboBox2
Range("C" & L).Value = TextBox1
Range("D" & L).Value = TextBox2
Range("E" & L).Value = TextBox3
Range("F" & L).Value = TextBox4
Range("G" & L).Value = TextBox5
Range("H" & L).Value = TextBox6
Range("I" & L).Value = TextBox7
Range("J" & L).Value = TextBox8
Range("K" & L).Value = TextBox9
MsgBox ("Apres avoir créé un nouveau salarié dans la BASE DE DONNEES ne pas oublier de l'ajouter dans PRH ainsi que dans son SECTEUR d'activité ")
End If
End Sub
'Pour le bouton Modifier
Private Sub CommandButton2_Click()
Dim Ligne As Long
Dim I As Integer
If MsgBox("Confirmez-vous la modification de ce contact ?", vbYesNo) = vbYes Then
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
Ws.Cells(Ligne, "B") = ComboBox2
For I = 1 To 9
If Me.Controls("TextBox" & I).Visible = True Then
Ws.Cells(Ligne, I + 2) = Me.Controls("TextBox" & I)
End If
Next I
End If
End Sub
'Pour le bouton Quitter
Private Sub CommandButton3_Click()
Unload Me 'quitte l'interface
End Sub