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
| Private Sub txtSortie_Change()
optSortie = Me.txtSortie <> ""
optEntree = Me.txtSortie = ""
End Sub
Private Sub cmdImprimer_Click()
Dim c As Range, v As Range, w As Range, Sce As Range
Dim Ftickets As Worksheet, Fnoyau As Worksheet
Dim Dest As Integer
Dim Txt As String
Dim N As Long
Set Fnoyau = ThisWorkbook.Worksheets("Noyau")
Set Ftickets = ThisWorkbook.Worksheets("Tickets")
With Fnoyau
.Visible = True
If optEntree = True Then
Set Sce = Ftickets.Columns(4)
Dest = 1
Txt = Me.txtEntree.Value
Else
Set Sce = Ftickets.Columns(6)
Dest = 4
Txt = Me.txtSortie.Value
End If
Set c = Sce.Find(Txt, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
N = .Cells(.Rows.Count, Dest).End(xlUp).Row
For Each v In .Cells(3, Dest).Resize(N - 2)
Set w = Ftickets.Rows(5).Find(v, LookIn:=xlValues, LookAt:=xlWhole)
If Not w Is Nothing Then
v.Offset(, 2) = Intersect(c.EntireRow, w.EntireColumn)
Set w = Nothing
End If
Next v
Set c = Nothing
Else
MsgBox "Le code recherché n'existe pas", vbOKOnly, "Erreur"
End If
End With
Set Fnoyau = Nothing
Set Ftickets = Nothing
Unload Me
End Sub |
Partager