A voir également:
- Problème sur une boucle For Each
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Idm for mac - Télécharger - Téléchargement & Transfert
- Copytrans heic for windows - Télécharger - Visionnage & Diaporama
- Instagram for pc - Télécharger - Divers Communication
- Microsoft store download for pc - Guide
1 réponse
Bonjour,
Ai pas trouve le pourquoi, mais essayez ceci, cela evite les boucles:
Ai pas trouve le pourquoi, mais essayez ceci, cela evite les boucles:
Sub test()
Dim Cellmax As Variant
Dim Cellcount
Dim MaxLocal
Dim Ligne
Dim Workcol
Dim AED
Ligne = 3
Workcol = 4
Cellcount = 0
AED = 2
Do Until Rows(Ligne).Columns(1) = Empty
Cellcount = WorksheetFunction.CountA(Range(Rows(Ligne).Columns(Workcol), Rows(Ligne).Columns(Workcol + 5)))
' Fin du compteur
If Cellcount <> 0 Then
MaxLocal = WorksheetFunction.Max(Rows(Ligne + 2).Columns(AED), Rows(Ligne + 1).Columns(AED), Rows(Ligne).Columns(AED), Rows(Ligne - 1).Columns(AED), Rows(Ligne - 2).Columns(AED))
'Detection du maximun
Set Cellmax = Range(Rows(Ligne - 2).Columns(AED), Rows(Ligne + 2).Columns(AED)).Find(MaxLocal, lookat:=xlWhole)
If Not Cellmax Is Nothing Then
MsgBox "Here your max"
Cellmax.Activate
End If
End If
Ligne = Ligne + 1
Loop
End Sub
Toutefois, je ne connais pas le code pour cette partie :
Notamment la partie "If Not Cellmax is Nothing", Set Cellmax pour définir la case à partir d'une recherche, ça je comprend l'idée, mais pour définir l'action, pourriez-vous m'expliquer la syntaxe svp ?
If Not Cellmax Is Nothing Then: c'est un test au cas ou ce que vous cherchez n'est pas dans la plage de cellules. Definir la variable en variant, si la recherche .find n'est pas ok, la variable prend la valeur nothing et si c'est ok la variable prend les caracteristiques de le cellule trouvee(valeur,adresse......).