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
| Private Sub UserForm_Initialize()
Dim Ws As Worksheet
ComboBox1.Clear
For Each Ws In ThisWorkbook.Worksheets
If Ws.Name <> "TB" Then
ComboBox1.AddItem Ws.Name
End If
Next Ws
With Sheets("TB")
ComboBox2.List = .Range("A2:A" & .Range("A65536").End(xlUp).Row).Value
End With
TextBox1.Value = Format(Date, "dd/mm/yyyy")
End Sub
Private Sub CommandButton2_Click()
Dim O As Worksheet
Dim LI As Long
Dim DA As Range
Set O = Sheets(Me.ComboBox1.Value)
If ComboBox1.Value = "" Or ComboBox2.Value = "" Or TextBox1.Value = "" Or TextBox2.Value = "" Then
MsgBox ("Veuillez remplir tous les champs pour continuer")
Exit Sub
End If
If MsgBox("Etes-vous certain de vouloir enregistrer ces nouvelles données ?", vbYesNo + vbInformation, "Demande de confirmation") = vbYes Then
Set DA = O.Range("A:A").Find(Date)
If DA Is Nothing Then MsgBox "Date non trouvée !": Exit Sub
LI = DA.Row
O.Cells(LI, Me.ComboBox2.ListIndex + 5).Value = CDbl(TextBox2.Value)
End If
Unload Me
UserForm1.Show
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub |