Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

find dans un tableau()

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

kevenpom

XLDnaute Junior
Est-il possible de faire un .find dans un tableau qui amméliore la vitesse d'exécution.

Merci




Code:
Dim WS1, WS2 As Worksheet
Dim lastrow, lastrow2, Source_inv, Source_decomposition, maxinv, maxdecomp, i, L, k, m, x As Long
Set WS1 = ThisWorkbook.Sheets("inv")
Set WS2 = ThisWorkbook.Sheets("decomposition")
maxinv = WS1.Range("A65536").End(xlUp).Row
maxdecomp = WS2.Range("A65536").End(xlUp).Row
Source_inv = WS1.Range(WS1.Range("A1"), WS1.Range("c" & maxinv)).Value
Source_decomposition = WS2.Range(WS2.Range("A1"), WS2.Range("U" & maxdecomp)).Value

Dim tablo(25000, 18) As String
For i = 1 To maxdecomp

    For k = 1 To maxinv
        If Source_decomposition(i, 1) = Source_inv(k, 1) Then
            tablo(i, 2) = Source_inv(k, 2)
            tablo(i, 1) = Source_inv(k, 3)
        End If
    Next k
 
Re : find dans un tableau()

Bonjour,
essaie déjà ceci:
Code:
Dim WS1, WS2 As Worksheet
Dim lastrow, lastrow2, Source_inv, Source_decomposition, maxinv, maxdecomp, i, L, k, m, x As Long
Set WS1 = ThisWorkbook.Sheets("inv")
Set WS2 = ThisWorkbook.Sheets("decomposition")
maxinv = WS1.Range("A65536").End(xlUp).Row
maxdecomp = WS2.Range("A65536").End(xlUp).Row
Source_inv = WS1.Range(WS1.Range("A1"), WS1.Range("c" & maxinv)).Value
Source_decomposition = WS2.Range(WS2.Range("A1"), WS2.Range("U" & maxdecomp)).Value

Dim tablo(25000, 18) As String
Application.Screenupdating=false
Application.Calculation = xlCalculationManual

For i = 1 To maxdecomp

    For k = 1 To maxinv
        If Source_decomposition(i, 1) = Source_inv(k, 1) Then
            tablo(i, 2) = Source_inv(k, 2)
            tablo(i, 1) = Source_inv(k, 3)
        End If
    Next k

Application.Calculation = xlAutomatic
Application.Screenupdating=true
A+
 
Dernière édition:
Re : find dans un tableau()

Bonjour ca demeure très long quand même.

Code:
tablo(i, 2) = Application.Match(Source_decomposition(i, 1), Application.Index(Source_inv, , 1), 0)

me donne erreur d'incompatibilité de type 13

avec une dictionnaire peut-être ?
Je sais comment la faire pour une feuille excel mais dans un tableau j'ai un doute.


Car une voit la valeur trouver sur ma feuille inventaire je doit retourné LE Sourceinv(x,2 et 3) prix et qty pour l'inscrire dans mon tablo(i,2 et,3).

Merci
 
Re : find dans un tableau()

Je la lisait en ce moment mais,
je bug rendu ici



Code:
Sub cout_dispo()
Application.ScreenUpdating = False
Dim WS1, WS2 As Worksheet
Dim lastrow, lastrow2, Source_inv, Source_decomposition, maxinv, maxdecomp, mondico, i, L, k, m, x, clé, val1, val2, ligne As Long
Set WS1 = ThisWorkbook.Sheets("inv")
Set WS2 = ThisWorkbook.Sheets("decomposition")
maxinv = WS1.Range("A65536").End(xlUp).Row
maxdecomp = WS2.Range("A65536").End(xlUp).Row
Set mondico = CreateObject("scripting.dictionary")
Source_inv = WS1.Range(WS1.Range("A1"), WS1.Range("c" & maxinv)).Value
Source_decomposition = WS2.Range(WS2.Range("A1"), WS2.Range("U" & maxdecomp)).Value
Dim tablo(25000, 18) As Long
For i = 1 To maxdecomp
    For k = 1 To maxinv - 1
        mondico(Source_inv(k, 1)) = k
    Next k
  clé = Source_decomposition(i, 1)
  ligne = mondico(clé)
  tablo(i, 7) = Source_inv(k, 1)(ligne, 2)
  tablo(i, 8) = Source_inv(k, 1)(ligne, 3)
Next i
 
Dernière édition:
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
5
Affichages
705
Réponses
4
Affichages
581
  • Question Question
Microsoft 365 VBA Transpose
Réponses
11
Affichages
869
Réponses
5
Affichages
477
Réponses
10
Affichages
533
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
1 K
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…