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
| rivate Sub Commandbutton1_Click()
Dim L As Integer
Dim existe As Long
Dim Ws As Worksheet, liste As Object, xL
Dim Sh As Worksheet
'Ajout des informations sur la matrice
If MsgBox("Etes-vous certain de vouloir Créer ce nouveau SOP ?", vbYesNo, "Demande de confirmation") = vbYes Then 'condition : si oui au message
L = Sheets("Index").Range("a65536").End(xlUp).Row + 1 'Permet de se positionner sur la dernière ligne de tableau NON VIDE
Range("A" & L).Value = ComboBox1 'Insère la donnée dans la colonne A
Range("B" & L).Value = ComboBox2 'Insère la donnée dans la colonne B
Range("C" & L).Value = TextBox4 'Insère la donnée dans la colonne C
Range("F" & L).Value = TextBox1 'Insère la donnée dans la colonne F
End If
ActiveWorkbook.Worksheets("Index").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Index").AutoFilter.Sort.SortFields.Add Key:=Range( _
"A2:A226"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Index").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Création du modèle tableau dans la nouvel feuil nommé
If Me.TextBox2 = "" Then Exit Sub
On Error Resume Next
Sheets(Me.TextBox2.Text).Visible = True
existe = Err.Number
On Error GoTo 0
If existe > 0 Then
Sheets("Modele_sop").Select 'je selectionne mon model
Sheets("Modele_sop").Copy after:=Worksheets(Worksheets.Count) 'je crée le nouvel onglet à partir du model
ActiveSheet.Name = Me.TextBox2 'je nomme le nouvel onglet
Else
MsgBox "le SOP " & TextBox2 & " existe déjas !" 'si le nouvel onglet exciste
End If
Unload Me
Unload Me
End Sub |
Partager