Sub test1()
Dim Arr
Dim Dern As Long, Clé1 As String, Clé2 As String
Dim Sh As Worksheet
Set Sh = ThisWorkbook.Worksheets("Feuil1")
Dern = Sh.Cells(Sh.Rows.Count, 1).End(xlUp).Row
j = 2
For i = 2 To Dern
If Range("F" & i).Value Like "*-C_*" Then
Range("L" & j).Value = Range("C" & i).Value
Range("M" & j).Value = "=mid(F" & i & ",search(""-C_"",F" & i & ")+3,7)"
Range("L" & j + 1).Value = Range("C" & i).Value
Range("M" & j + 1).Value = "'" & Range("D" & i).Value
j = j + 2
End If
Next i
End Sub
RE...Re
voila les amis le code il est lent vu le nombre de ligne mais il est très efficace
Sub Supprimer()
Dim Derlg&
Application.ScreenUpdating = False
With Feuil1
.AutoFilterMode = False
.Columns("I:K").Insert
Derlg = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
.Range("i3:i" & Derlg).Formula = "=c3&d3"
.Range("j3:j" & Derlg).Formula = "=IF(ISNUMBER(MID(F3,FIND(""-C_"",F3)+3,7)*1),C3&MID(F3,FIND(""-C_"",F3)+3,7),"""")"
.Range("k3:k" & Derlg).Formula = "=COUNTIF($i$3:$I$" & Derlg & ",$J3)+COUNTIF($j$3:$J$" & Derlg & ",$I3)"
On Error Resume Next 'rien à filtrer
.Range("a2:k" & Derlg).AutoFilter Field:=11, Criteria1:=">0"
.Range("a2:h" & Derlg).Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.Columns("I:K").Delete
.[a2].AutoFilter
End With
End Sub
Sub test1()
Dim f As Long, num As Long
f = Range("F" & Rows.Count).End(xlUp).Row
Dim Tablo()
ReDim Tablo(0)
num = 0
For i = 2 To f
If Range("F" & i) Like "*-C_*" Then
On Error Resume Next
If Tablo(num - 1) <> Split(Range("F" & i), "_")(1) Then
Tablo(num) = Split(Range("F" & i), "_")(1)
num = num + 1
ReDim Preserve Tablo(num)
End If
End If
Next i
For t = LBound(Tablo) To UBound(Tablo) - 1
For j = f To 2 Step -1
If Range("I" & j) Like "ACH" & Tablo(t) & "*" Then Range("I" & j).EntireRow.Delete
Next j
Next t
End Sub
If Range("F" & i) Like "*-C_*" Then
On Error Resume Next
If Tablo(num - 1) <> Split(Range("F" & i), "_")(1) Then
Tablo(num) = Split(Range("F" & i), "_")(1)
num = num + 1
ReDim Preserve Tablo(num)
End If
End If
Dim f As Long, num As Long
f = Range("F" & Rows.Count).End(xlUp).Row
Dim Tablo()
ReDim Tablo(0, 1)
num = 0
For i = 2 To f
If Range("F" & i) Like "*-C_*" Then
On Error Resume Next
If Tablo(num - 1, 1) <> Split(Range("F" & i), "_")(1) And Tablo(num - 1, 0) <> Range("F" & i).Offset(0, -3) Then
Tablo(num, 0) = Range("F" & i).Offset(0, -3)
Tablo(num, 1) = Split(Range("F" & i), "_")(1)
num = num + 1
ReDim Preserve Tablo(num)
End If
End If
Next i
For t = LBound(Tablo) To UBound(Tablo)
For j = f To 2 Step -1
If Range("I" & j) Like Tablo(t, 0) & Tablo(t, 1) & "*" Then Range("I" & j).EntireRow.Delete
Next j
Next t
Mille merci MrJe ferais des tests plus poussés dès que je pourrais (le Lundi est compliqué pour moi, beaucoup de travail)
A +
For i = 18 To f
If Range("F" & i) Like "*-C_*" Then
On Error Resume Next
Tablo(num) = Split(Range("F" & i), "_")(1)
num = num + 1
ReDim Preserve Tablo(num)
Tablo(num) = Range("D" & i)
num = num + 1
ReDim Preserve Tablo(num)
End If
Next i
Oui j'avais fais ça à la base mais ça fait un tableau à 1 dimension il manque le code à 3 lettres.Mille merci Mr
j'ai trouver la manière de remplir le Tablo avec tous les pièces que je doit les supprimer mais mon Tablo contient des doublons
VB:For i = 18 To f If Range("F" & i) Like "*-C_*" Then On Error Resume Next Tablo(num) = Split(Range("F" & i), "_")(1) num = num + 1 ReDim Preserve Tablo(num) Tablo(num) = Range("D" & i) num = num + 1 ReDim Preserve Tablo(num) End If Next i
Regarde la pièce jointe 1121541
je vais cherché de mon coter cette semaine
prenez tous votre temps je ne suis pas percés
merci encore une fois
Sub tbrfv()
Dim arr
Dim f As Long, num As Long
dern = Range("F" & Rows.Count).End(xlUp).Row
Set d = CreateObject("Scripting.Dictionary")
arr = Range("A3:H" & dern)
For i = LBound(arr) To UBound(arr)
If arr(i, 6) Like "*-C_*" Then
Cle1 = arr(i, 3) & Split(arr(i, 6), "_")(1)
Cle2 = arr(i, 3) & arr(i, 4)
If Not d.exists(Cle1) And Not d.exists(Cle2) Then
d.Add Cle1, Cle1
d.Add Cle2, Cle2
End If
End If
Next i
End Sub