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
| Option Explicit
Public Sub test()
Dim listMots As New Collection
Dim c As Range
For Each c In Sheets("trie").[A1].CurrentRegion
listMots.Add c.Text
Next c
Dim r As Range
Set r = Sheets("Base de donnée").UsedRange
supprimerLesLignesContenant listMots, r
End Sub
Private Sub supprimerLesLignesContenant(ByRef listeMotsInterdits As Collection, ByRef rg As Range)
Dim iCol, iRow As Long
Dim i As Integer
Dim currentValue As String
Dim toDelete As Boolean
iRow = rg.Rows.Count
Do While iRow >= 1
iCol = rg.Columns.Count
Do While iCol >= 1
currentValue = rg.Cells(iRow, iCol).Text
i = 0
toDelete = False
If currentValue <> "" Then
Do While i <= listeMotsInterdits.Count And toDelete = False
If InStr(listeMotsInterdits(i), currentValue) > 0 Then
toDelete = True
Else
i = i + 1
End If
Loop
End If
If toDelete Then
iCol = 0
rg.Cells(iRow, 1).EntireRow.Delete
Else
iCol = iCol - 1
End If
Loop
iRow = iRow - 1
Loop
End Sub |
Partager