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 55 56 57 58 59 60 61 62 63 64 65
|
Option Explicit
Dim Ligne As Long
Private Sub UserForm_Initialize()
'CboDate = Date_Visite
Dim J As Long
With Sheets("Données")
For J = 4 To .Range("A" & Rows.Count).End(xlUp).Row
Me.CboDate.AddItem .Range("A" & J)
Next J
End With
CboDate.Value = Format(CboDate.Value, "dd/mm/yy")
End Sub
Private Sub CboDate_Change()
Dim Ctrl As Control
Dim Colonne As Integer
If Me.CboDate.ListIndex = -1 Then Exit Sub
With Sheets("Données")
Ligne = Me.CboDate.ListIndex + 4
For Each Ctrl In Me.Controls
Colonne = CInt("0" & Ctrl.Tag)
If Colonne > 0 Then Ctrl = .Cells(Ligne, Colonne)
Next Ctrl
End With
End Sub
Function TrouveType(V)
TrouveType = V
If IsDate(TrouveType) = True And InStr(TrouveType, "/") <> 0 And InStr(TrouveType, ":") <> 0 Then TrouveType = Format(TrouveType, "yyyy-mm-dd hh:mm"): Exit Function
If IsDate(TrouveType) = True And InStr(TrouveType, "/") <> 0 Then TrouveType = Format(TrouveType, "yyyy-mm-dd"): Exit Function
If IsNumeric(Replace(TrouveType, ".", ",")) = True Then TrouveType = Replace(TrouveType, ",", "."): Exit Function
End Function
Private Sub CmdModifier_Click()
' Modifier
Dim Ctrl As Control
Dim Colonne As Integer
Dim Ligne As Long
If Me.CboDate.ListIndex = -1 Then Exit Sub
Ligne = Me.CboDate.ListIndex + 4
With Sheets("Données")
For Each Ctrl In Me.Controls
Colonne = Val(Ctrl.Tag)
If Colonne > 0 Then
.Cells(Ligne, Colonne) = TrouveType(Ctrl)
End If
Next Ctrl
.Cells(Ligne, Sheets("Données").UsedRange.Columns.Count) = Sheets("Feuil1").Range("C24")
End With
Unload Me
End Sub
Private Sub CmdAnnuler_Click()
Unload Me
End Sub |
Partager