Bonjour,
Je fais une macro dans laquelle j'utilise les fonctions Find() et FindNext() afin de parcourir tous mes résultats :
Jusque là pas de soucis.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 Set CellIng = Sheets("2012").Range("BL:BL").Find(sNom, LookIn:=xlValues) If Not CellIng Is Nothing Then PremiereLigne = CellIng.Address Do nLigSem = CellIng.Row nColSem = CellIng.Column Do ' TRAITEMENT nColSem = nColSem + 1 Loop While Sheets("2012").Cells(nLigSem, nColSem).Value > Sheets("2012").Cells(nLigSem, nColSem - 1).Value Set CellIng = Sheets("2012").Range("BL:BL").FindNext(CellIng) Loop While Not CellIng Is Nothing And CellIng.Address <> PremiereLigne End If
Par contre dans ma deuxième boucle, je fait une deuxième recherche :
J'obtient donc le code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 Set CellPast = Sheets("J PRJ").Rows("1:1").Find(Sheets("2012").Cells(nLigSem, nColSem).Value, LookIn:=xlValues) If Not CellPast Is Nothing Then Sheets("J PRJ").Cells(i, CellPast.Column).Value = Sheets("J PRJ").Cells(i, CellPast.Column).Value + Sheets("2012").Cells(CellIng.Row, nColSem).Value End If
Le soucis, c'est que du coup ma fonction FindNext() me renvoie 'Nothing' dès le premier appel.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 Set CellIng = Sheets("2012").Range("BL:BL").Find(sNom, LookIn:=xlValues) If Not CellIng Is Nothing Then PremiereLigne = CellIng.Address Do nLigSem = CellIng.Row nColSem = CellIng.Column Do Set CellPast = Sheets("J PRJ").Rows("1:1").Find(Sheets("2012").Cells(nLigSem, nColSem).Value, LookIn:=xlValues) If Not CellPast Is Nothing Then ' Coller en additionnant Sheets("J PRJ").Cells(i, CellPast.Column).Value = Sheets("J PRJ").Cells(i, CellPast.Column).Value + Sheets("2012").Cells(CellIng.Row, nColSem).Value End If nColSem = nColSem + 1 Loop While Sheets("2012").Cells(nLigSem, nColSem).Value > Sheets("2012").Cells(nLigSem, nColSem - 1).Value Set CellIng = Sheets("2012").Range("BL:BL").FindNext(CellIng) Loop While Not CellIng Is Nothing And CellIng.Address <> PremiereLigne End If
Alors qu'il ya a bien plusieures occurrences qui me sont correctement renvoyées si j'enlève mon 2ème appel à la fonction Find()
J'ai beau chercher dans la doc, je ne trouve pas pourquoi il est impossible de procéder ainsi !
Si quelqu'un à une petite idée
Merci
Partager