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
| Sub SelectNiet()
Dim cls As Range, x As Long, y As Long, cel As Range, nblg As Long, nbcol As Long, plage As Range, trouve As String
Dim col As String
With Sheets("e")
y = 1
nbcol = .Range("A1").SpecialCells(xlCellTypeLastCell).Column
For x = 1 To nbcol
col = Split(.Cells(1, x).Address, "$")(1)
nblg = .Range(col & .Rows.Count).End(xlUp).Row
Set plage = Range(col & nblg, Range(col & nblg).End(xlUp))
For Each cel In plage
If .Cells(y + 1, x) <> "niet" And y < nblg Then
y = y + 1
End If
Set plage = .Range(.Cells(y, x), .Cells(nblg, x))
'Set cls = Nothing
Set cls = plage.Find("niet", .Cells(y, x), , , xlByColumns)
If Not cls Is Nothing Then
If trouve = "" Then
trouve = cls.Address
Else
trouve = trouve & "," & cls.Address
End If
y = cls.Row
End If
Next cel
y = 1
Next x
.Range(trouve).Select
End With
End Sub |
Partager