Option Explicit
Sub Test()
Application.ScreenUpdating = False
Dim WsS As Worksheet, WsC As Worksheet, TDévia(), Ld&, TWorkon(), Lw&, TRésu()
' Dim Te(1 To 500) As String, Le As Long ' Variables globales module. Inutilisés ici
Set WsS = Worksheets("Workon")
Set WsC = Worksheets("Data-Deviations")
TDévia = WsC.Range("AG2:AG" & WsC.Range("AG" & Rows.Count).End(xlUp).Row).Value
ReDim TRésu(1 To UBound(TDévia), 1 To 1)
TWorkon = WsS.Range("S2:T" & WsS.Range("S" & Rows.Count).End(xlUp).Row).Value
For Ld = 1 To UBound(TDévia)
For Lw = 1 To UBound(TWorkon)
If InStr(TDévia(Ld, 1), TWorkon(Lw, 1)) > 0 Then Ajouter TWorkon(Lw, 2)
Next Lw
TRésu(Ld, 1) = RésultatCellClassé: Next Ld
WsC.[AI2].Resize(UBound(TRésu)).Value = TRésu
' Application.ScreenUpdating = True ' N'apporte rien : Assumé après exécution
' Application.Calculation = xlAutomatic ' Il n'a pas été mis XlManual que je sache.
End Sub
If Le = 0 Then RésultatCellClassé = "*Aucune correspondance*": Exit Function
.Init 0, Le: While .Actif: .BInfA = Te(.B) < Te(.A): Wend
Option Explicit
Dim Te(1 To 500) As String, Le As Long ' Variables globales module
Sub Ajouter(ByVal Z As String)
Le = Le + 1: Te(Le) = Z
End Sub
Function RésultatCellClassé() As String
Dim Ts() As String, Ls&, Texte As String ' Variables locales (volatiles)
If Le = 0 Then RésultatCellClassé = "*Aucune correspondance*": Exit Function
ReDim Ts(0 To Le - 1): Ls = -1
With New TableIndex
.Init 1, Le: While .Actif: .BInfA = Te(.B) < Te(.A): Wend
Texte = ""
.Parcourir: While .Actif: Le = .Suivant
If Te(Le) <> Texte Then Texte = Te(Le): Ls = Ls + 1: Ts(Ls) = Texte
Wend: End With
ReDim Preserve Ts(0 To Ls)
RésultatCellClassé = Join(Ts, vbLf)
Le = 0
End Function
Potential deviation |
*Aucune correspondance* |
Drilling_Holes_elongated Drilling_issue |
Drilling_Holes_position |
*Aucune correspondance* |
Drilling_Oversize Drilling_issue |