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
| Option Explicit
Dim L As Integer
Private Sub CommandButton1_Click()
Dim PlageRecherche As Range
Dim test As Boolean
test = False
While (test = False)
If TextBox1 = "" Or TextBox1 = "" Or TextBox2 = "" Or TextBox3 = "" Or TextBox4 = "" Or TextBox5 = "" Or ComboBox2 = "" Or ComboBox3 = "" Or ComboBox4 = "" Then
MsgBox ("Saisie incomplète, veuillez remplir tout les champs")
Else
If MsgBox(" Confirmez-vous linsertion de cette anomaie ? ", vbYesNo) = vbYes Then
L = Sheets("Suivi").Range(" a65536 ").End(xlUp).Row + 1
Sheets("Suivi").Range("B" & L).Value = CStr(ComboBox1.Value)
Set PlageRecherche = Sheets("DATA").Range("A:A").Find(what:=ComboBox1, LookIn:=xlValues, lookat:=xlWhole)
If PlageRecherche Is Nothing Then
L = Sheets("DATA").Range("A" & Rows.Count).End(xlUp).Row + 1
Sheets("DATA").Range("A" & L).Value = CStr(ComboBox1.Value)
End If
ActiveWorkbook.Worksheets("DATA").ListObjects("Tableau1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("DATA").ListObjects("Tableau1").Sort.SortFields.Add _
Key:=Range("A2"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("DATA").ListObjects("Tableau1").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
L = Sheets("Suivi").Range(" a65536 ").End(xlUp).Row + 1
Sheets("Suivi").Range("D" & L).Value = CStr(ComboBox2.Value)
Sheets("Suivi").Range("C" & L).Value = CStr(ComboBox3.Value)
Sheets("Suivi").Range("H" & L).Value = CStr(ComboBox4.Value)
Sheets("Suivi").Range("E" & L).Value = CStr(TextBox1.Value)
Sheets("Suivi").Range("F" & L).Value = CStr(TextBox2.Value)
Sheets("Suivi").Range("G" & L).Value = CStr(TextBox3.Value)
Sheets("Suivi").Range("I" & L).Value = CStr(TextBox5.Value)
Sheets("Suivi").Range("A" & L).Value = CStr(TextBox4.Value)
Sheets("Suivi").Range("j" & L).Value = "Nouveau"
Sheets("Suivi").Range("K" & L).Value = "TBD"
Unload Me
test = True
End If
End If
Wend
End Sub |
Partager