Bonjour MichD, Je n'ai pas de soucis sur ce point :
Remplace ceci R(Compteur) = T(i, 1) par R(Compteur) = i
Bon voila un code simplifié ou j'ai besoin d'une solution en cas ou mo t="tous" (Ca veut dire le tableau r est vide : UBound(r)=-1) : '------------ Sub RechercheTb() Dim B() Dim Mot As String, rL1, rL2 Set rL1 = CreateObject("System.Collections.ArrayList") Set rL1 = CreateObject("System.Collections.ArrayList") ReDim B(1 To 25) B(1) = "<! AA (TIT);" B(2) = "120121" B(3) = "120122" B(4) = "120121" B(5) = "<! AB (MJD);" B(6) = "147852" B(7) = "147853" B(8) = "147854" B(9) = "147855" B(10) = "<! BC (TIT);" B(11) = "898874" B(12) = "898875" B(13) = "898876" B(14) = "<! SD (FGD);" B(15) = "325698" B(16) = "325699" B(17) = "<! ZE (TIT);" B(18) = "111478" B(19) = "111479" B(20) = "111480" B(21) = "<! HC (MJD);" B(22) = "251448" B(23) = "251449" B(24) = "251450" Mot = Sheets("Feuil1").Range("T3") If Mot <> "tous" Then FcNm = "Clients " & Mot & ".txt" Else FcNm = "Clients global.txt" End If If Mot <> "tous" Then For i = LBound(B) To UBound(B) If InStr(1, B(i), Mot) > 0 Then rL1.Add i End If Next End If r = rL1.Toarray() For j = LBound(r) To UBound(r) Debug.Print "Agence en cours : " & B(r(j)) ' Boucle sur le tableau (B) des données à traiter For Z = r(j) + 1 To UBound(B) ' Si c'est un numéro If IsNumeric((B(Z))) Then Debug.Print B(Z) ' rL2.Add B(Z) Else ' C'est un nom d'agence Debug.Print B(Z) GoTo nt: End If Next nt: Next End Sub '------------ Merci.
Bonjour MichD,
Je n'ai pas de soucis sur ce point :
Remplace ceci R(Compteur) = T(i, 1) par R(Compteur) = i
Bon voila un code simplifié ou j'ai besoin d'une solution en cas ou mo t="tous" (Ca veut dire le tableau r est vide : UBound(r)=-1) :
'------------
Sub RechercheTb()
Dim B()
Dim Mot As String, rL1, rL2
Set rL1 = CreateObject("System.Collections.ArrayList")
Set rL1 = CreateObject("System.Collections.ArrayList")
If Mot <> "tous" Then
FcNm = "Clients " & Mot & ".txt"
Else
FcNm = "Clients global.txt"
End If
If Mot <> "tous" Then
For i = LBound(B) To UBound(B)
If InStr(1, B(i), Mot) > 0 Then
rL1.Add i
End If
Next
End If
r = rL1.Toarray()
For j = LBound(r) To UBound(r)
Debug.Print "Agence en cours : " & B(r(j))
' Boucle sur le tableau (B) des données à traiter
For Z = r(j) + 1 To UBound(B)
' Si c'est un numéro
If IsNumeric((B(Z))) Then
Debug.Print B(Z)
' rL2.Add B(Z)
Else ' C'est un nom d'agence
Debug.Print B(Z)
GoTo nt:
End If
Next
nt:
Next
End Sub
'------------
Bonjour MichD, Je n'ai pas de soucis sur ce point :
Remplace ceci R(Compteur) = T(i, 1) par R(Compteur) = i
Bon voila un code simplifié ou j'ai besoin d'une solution en cas ou mo t="tous" (Ca veut dire le tableau r est vide : UBound(r)=-1) : '------------ Sub RechercheTb() Dim B() Dim Mot As String, rL1, rL2 Set rL1 = CreateObject("System.Collections.ArrayList") Set rL1 = CreateObject("System.Collections.ArrayList") ReDim B(1 To 25) B(1) = "<! AA (TIT);" B(2) = "120121" B(3) = "120122" B(4) = "120121" B(5) = "<! AB (MJD);" B(6) = "147852" B(7) = "147853" B(8) = "147854" B(9) = "147855" B(10) = "<! BC (TIT);" B(11) = "898874" B(12) = "898875" B(13) = "898876" B(14) = "<! SD (FGD);" B(15) = "325698" B(16) = "325699" B(17) = "<! ZE (TIT);" B(18) = "111478" B(19) = "111479" B(20) = "111480" B(21) = "<! HC (MJD);" B(22) = "251448" B(23) = "251449" B(24) = "251450" Mot = Sheets("Feuil1").Range("T3") If Mot <> "tous" Then FcNm = "Clients " & Mot & ".txt" Else FcNm = "Clients global.txt" End If If Mot <> "tous" Then For i = LBound(B) To UBound(B) If InStr(1, B(i), Mot) > 0 Then rL1.Add i End If Next End If r = rL1.Toarray() For j = LBound(r) To UBound(r) Debug.Print "Agence en cours : " & B(r(j)) ' Boucle sur le tableau (B) des données à traiter For Z = r(j) + 1 To UBound(B) ' Si c'est un numéro If IsNumeric((B(Z))) Then Debug.Print B(Z) ' rL2.Add B(Z) Else ' C'est un nom d'agence Debug.Print B(Z) GoTo nt: End If Next nt: Next End Sub '------------ Merci.
MichD
! d'une solution en cas ou mot="tous Si tu veux obtenir tous les éléments, pourquoi faire ce test dans le bout de code suivant ? '----------------------------------------- If Mot <> "tous" Then For i = LBound(B) To UBound(B) If InStr(1, B(i), Mot) > 0 Then '<<========== rL1.Add i End If Next End If '----------------------------------------- Essaie plutôt comme ceci : '----------------------------------------- If Mot <> "tous" Then For i = LBound(B) To UBound(B) If InStr(1, B(i), Mot) > 0 Then rL1.Add i End If Next Else 'Dans le cas où MOT = "TOUS" 'Tu ne fais pas le test If instr(...) >0 For i = LBound(B) To UBound(B) rL1.Add i Next End If '----------------------------------------- MichD
! d'une solution en cas ou mot="tous
Si tu veux obtenir tous les éléments, pourquoi faire ce test dans le bout de code suivant ?
'-----------------------------------------
If Mot <> "tous" Then
For i = LBound(B) To UBound(B)
If InStr(1, B(i), Mot) > 0 Then '<<========== rL1.Add i
End If
Next
End If
'-----------------------------------------
Essaie plutôt comme ceci :
'-----------------------------------------
If Mot <> "tous" Then
For i = LBound(B) To UBound(B)
If InStr(1, B(i), Mot) > 0 Then
rL1.Add i
End If
Next
Else
'Dans le cas où MOT = "TOUS"
'Tu ne fais pas le test If instr(...) >0
For i = LBound(B) To UBound(B)
rL1.Add i
Next
End If
'-----------------------------------------
! d'une solution en cas ou mot="tous Si tu veux obtenir tous les éléments, pourquoi faire ce test dans le bout de code suivant ? '----------------------------------------- If Mot <> "tous" Then For i = LBound(B) To UBound(B) If InStr(1, B(i), Mot) > 0 Then '<<========== rL1.Add i End If Next End If '----------------------------------------- Essaie plutôt comme ceci : '----------------------------------------- If Mot <> "tous" Then For i = LBound(B) To UBound(B) If InStr(1, B(i), Mot) > 0 Then rL1.Add i End If Next Else 'Dans le cas où MOT = "TOUS" 'Tu ne fais pas le test If instr(...) >0 For i = LBound(B) To UBound(B) rL1.Add i Next End If '----------------------------------------- MichD
Apitos
Bonjour MichD, La collection rL1 ne sert que pour déterminer les positions des en-t êtes (Noms d'agence et leurs circonscriptions) dans le tableau B. Apres dans une boucle, on pointe sur chaque position, pour commencer le rec ueillement des numéros qui lui appartiennent. '--------------------------- For i = LBound(B) To UBound(B) If Mot <> "Tous" Then If InStr(1, LCase(B(i)), LCase(Mot)) > 0 Then rL1.Add i End If Else If InStr(1, B(i), ";") > 0 Then rL1.Add i End If End If Next r = rL1.Toarray() ' Boucle sur le tableau (r) ' des positions correspondantes à mot For j = LBound(r) To UBound(r) ' Boucle sur le tableau (B) des données à traiter For Z = r(j) + 1 To UBound(B) '... Next Next '---------------------------
Bonjour MichD,
La collection rL1 ne sert que pour déterminer les positions des en-t êtes (Noms d'agence et leurs circonscriptions) dans le tableau B.
Apres dans une boucle, on pointe sur chaque position, pour commencer le rec ueillement des numéros qui lui appartiennent.
'---------------------------
For i = LBound(B) To UBound(B)
If Mot <> "Tous" Then
If InStr(1, LCase(B(i)), LCase(Mot)) > 0 Then
rL1.Add i
End If
Else
If InStr(1, B(i), ";") > 0 Then
rL1.Add i
End If
End If
Next
r = rL1.Toarray()
' Boucle sur le tableau (r)
' des positions correspondantes à mot
For j = LBound(r) To UBound(r)
' Boucle sur le tableau (B) des données à traiter
For Z = r(j) + 1 To UBound(B)
'...
Next
Next
'---------------------------
Bonjour MichD, La collection rL1 ne sert que pour déterminer les positions des en-t êtes (Noms d'agence et leurs circonscriptions) dans le tableau B. Apres dans une boucle, on pointe sur chaque position, pour commencer le rec ueillement des numéros qui lui appartiennent. '--------------------------- For i = LBound(B) To UBound(B) If Mot <> "Tous" Then If InStr(1, LCase(B(i)), LCase(Mot)) > 0 Then rL1.Add i End If Else If InStr(1, B(i), ";") > 0 Then rL1.Add i End If End If Next r = rL1.Toarray() ' Boucle sur le tableau (r) ' des positions correspondantes à mot For j = LBound(r) To UBound(r) ' Boucle sur le tableau (B) des données à traiter For Z = r(j) + 1 To UBound(B) '... Next Next '---------------------------
MichD
Je suppose que ton dernier message est la solution que tu appliques. MichD
Je suppose que ton dernier message est la solution que tu appliques.