find dans un tableau()

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
 

fhoest

XLDnaute Accro
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:

kevenpom

XLDnaute Junior
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
 

kevenpom

XLDnaute Junior
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:

Discussions similaires

Réponses
11
Affichages
335
Réponses
13
Affichages
930

Statistiques des forums

Discussions
312 379
Messages
2 087 771
Membres
103 662
dernier inscrit
rterterert