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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| Option Explicit
Dim lig&, flag As Boolean 'mémorisation
Private Sub CommandButton1_Click()
ComboBox1 = ""
ComboBox2 = ""
ComboBox3 = ""
ComboBox3.SetFocus
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Activate()
Dim i As Integer
For i = 2012 To 2020
ComboBox1.AddItem i
Next
For i = 1 To 12
ComboBox2.AddItem Application.Proper(Format(CDate("1/" & i), "mmmm"))
Next
For i = 1 To 31
ComboBox3.AddItem i
Next
'CommandButton1.Visible = False
End Sub
Private Sub CheckBox1_Change()
If CheckBox1 And Not flag Then
ComboBox1 = Year(Date)
ComboBox2.ListIndex = Month(Date) - 1
ComboBox3 = Day(Date)
End If
End Sub
Private Sub ComboBox1_Change()
Recherche
End Sub
Private Sub ComboBox2_Change()
Recherche
End Sub
Private Sub ComboBox3_Change()
Recherche
End Sub
Sub Recherche()
Dim dat$, tablo, i&
lig = 0
CheckBox1 = False
'CommandButton1.Visible = False
If ComboBox1.ListIndex < 0 Then ComboBox1 = ""
If ComboBox2.ListIndex < 0 Then ComboBox2 = ""
If ComboBox3.ListIndex < 0 Then ComboBox3 = ""
If ComboBox1 = "" Or ComboBox2 = "" Or ComboBox3 = "" Then Exit Sub
dat = ComboBox3 & "/" & ComboBox2.ListIndex + 1 & "/" & ComboBox1
If Not IsDate(dat) Then MsgBox "Date non valide !", 48: ComboBox3.SetFocus: Exit Sub
If CDate(dat) = Date Then flag = True: CheckBox1 = True: flag = False
With Feuil4
tablo = .Range("B6:D" & .[B65536].End(xlUp).Row)
For i = 1 To UBound(tablo)
If ComboBox3 = CStr(tablo(i, 1)) And ComboBox2 = tablo(i, 2) _
And ComboBox1 = CStr(tablo(i, 3)) Then lig = i + 5: Exit For
Next
' CommandButton1.Caption = IIf(lig, "Modifier", "Créer")
' CommandButton1.Visible = True
' If lig = 0 Then Exit Sub
'TextBox10 = .Cells(lig, "E")
'TextBox11 = .Cells(lig, "F")
'TextBox12 = .Cells(lig, "I")
'TextBox15 = .Cells(lig, "J")
'TextBox13 = .Cells(lig, "L")
'TextBox14 = .Cells(lig, "N")
End With
End Sub |
Partager