Le 25/04/22 à 04:22, ThierryP a écrit :
Range(T)...
Dans la procédure soumise, il y a une limitation. La variable "T"
contenant les adresses des cellules contenant la valeur recherchée ne
peut pas excéder 255 caractères, cela limite est limitatif sur une
grande plage de cellule où la variable "T" pourrait être plus grande que
255 caractères.
La procédure suivante est aussi très rapide et elle est non limitative
sur la longueur de la chaîne de caractères contenue dans la variable T.
'-------------------------------------------
Sub test()
Dim Rg As Range, Trouve As Range
Dim X As Variant, Adr As String
Dim T As String, Sh As Worksheet
Application.ScreenUpdating = False
Application.ScreenUpdating = False
'Nom Feuille à adapter
Set Sh = Worksheets("Feuil4")
With Sh
'Plage de cellule à adapter
Set Rg = .Range("A1:A10000")
End With
'X la valeur dont la ligne doit être masquée
X = 1
With Rg
Set Trouve = .Find(What:=X, After:=Sh.Cells(Rg.Count, Rg.Column), _
LookIn:=xlValues, Lookat:=xlPart, SearchOrder:=xlNext)
If Not Trouve Is Nothing Then
Adr = Trouve.Address
Do
T = T & "," & Trouve.Address(0, 0)
Set Trouve = .FindNext(Trouve)
If Len(T) > 240 Then
T = Right(T, Len(T) - 1)
With Sh
.Range(T).EntireRow.Hidden = True
T = ""
End With
End If
If Trouve Is Nothing Then Exit Do
Loop Until Trouve.Address = Adr
If T <> "" Then
T = Right(T, Len(T) - 1)
With Sh
.Range(T).EntireRow.Hidden = True
T = ""
End With
End If
End If
End With
Application.ScreenUpdating = False
Application.ScreenUpdating = False
End Sub
'-------------------------------------------
MichD