Bonjour à tous,
je cherche à stocker des lignes de plusieurs feuilles de mon classeur répondant à une condition dans un tableau pour ensuite coller ce tableau dans un nouveau classeur.
Morceau de ma procédure qui créé le tableau :
J'ai une erreur "mémoire insuffisante" sur la ligne.
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 'Création d'un tableau contenant mes lignes Dim TabE(), LE&, TabS(), LS&, C&, i& ReDim TabS(1 To 50000, 1 To 10) For i = LBound(Noms_feuilles) To UBound(Noms_feuilles) TabE = Sheets(Noms_feuilles(i)).UsedRange.Value If UBound(TabS, 2) < UBound(TabE, 2) Then ReDim Preserve TabS(1 To UBound(TabS, 1), 1 To UBound(TabE, 2)) <----- Ligne posant pb For LE = 1 To UBound(TabE, 1) If TabE(LE, Col) = 1 Then LS = LS + 1 For C = 1 To UBound(TabE, 2) TabS(LS, C) = TabE(LE, C) Next C End If Next LE Next i
Cette procédure fonctionnait très bine en utilisant le fait que mes données sont stockées dans mes feuilles sous forme de tableau comme ceci :
Cependant je cherche à enlever ces tableaux car ils me posent d'autres problèmes. Je me suis dit que le code ci-dessus (premier code) devait me donner l'équivalent sans tableau mais cela ne fonctionne pas ...
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 'Création d'un tableau contenant mes lignes Dim TabE(), LE&, TabS(), LS&, C&, i& ReDim TabS(1 To 50000, 1 To 10) For i = LBound(Noms_feuilles) To UBound(Noms_feuilles) TabE = Sheets(Noms_feuilles(i)).ListObjects(1).DataBodyRange.Value <---- ligne que j'ai changé avec UsedRange, pourtant pas celle qui pose problème ! If UBound(TabS, 2) < UBound(TabE, 2) Then ReDim Preserve TabS(1 To UBound(TabS, 1), 1 To UBound(TabE, 2)) For LE = 1 To UBound(TabE, 1) If TabE(LE, Col) = 1 Then LS = LS + 1 For C = 1 To UBound(TabE, 2) TabS(LS, C) = TabE(LE, C) Next C End If Next LE Next i
Auriez-vous une solution ?
Merci par avance !
Partager