Private Sub UserForm_Initialize()
[B][I]Dim lf As Long
Sheets("Primaire").Select
lf = Range("A65536").End(xlUp).Row
ComboBox1.Clear
For Each cel In Range("A2:A" & lf)
If cel.Value <> "" Then ComboBox1.AddItem cel.Value
Next cel [/I][/B]
' affichage valeur de départ pour calendrier ( Date d'aujourdhui )
datesortie.Value = "../../.."
UserForm_Activate
daterentree.Value = VBA.Format(VBA.Date, "dd/mm/yyyy")
UserForm_Activate
End Sub
Private Sub save_Click()
Dim Adh As String
Dim ref As String
Dim DtEnt As Date
Dim dtsort As Date
Dim nbH As Integer
Dim Lg As Long, dLg As Long
Adh = ComboBox1
DtEnt = daterentree
dtsort = datesortie
nbH = TextBox3
With Sheets("primaire")
dLg = .Range("R" & Rows.Count).End(xlUp).Row
Set R = ThisWorkbook.Sheets("primaire").Range("A:A").Find(what:=ComboBox1.Value, LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not R Is Nothing Then
Lg = R.Row + 1
While Cells(Lg, 1).Offset(0, 1) = "" And Lg <= dLg
Lg = Lg + 1
Wend
.Range("A" & Lg).EntireRow.Insert
Else
Lg = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & Lg) = what
End If
.Range("R" & Lg) = dtsort
.Range("S" & Lg) = nbH
.Range("T" & Lg) = DtEnt
End With
Unload Me
End Sub
Private Sub quit_Click()
Unload Me
End Sub
' mise en forme des calendriers
Private Sub UserForm_Activate()
With datesortie
.SetFocus
.SelStart = 0
.SelLength = Len(datesortie)
End With
With daterentree
.SetFocus
.SelStart = 0
.SelLength = Len(daterentree)
End With
End Sub
'affichage des calendriers
Private Sub datesortie_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
calendrier_incrementation.Show
End Sub
Private Sub daterentree_dblclick(ByVal Cancel As MSForms.ReturnBoolean)
calendrier_incrementation_entre.Show
End Sub
'valeur
Private Sub continuer_Click()
Selection = DateValue(datesortie.Value)
Unload Me
End Sub
Selection = DateValue(daterentree.Value)
Unload Me
End Sub