Bonjour,

J'essaye de coder en vba la copie d'un tableau d'un fichier excel vers un autre fichier excel. La copie se faire ligne par ligne. Seulement, mon code bug, et m'affiche "Erreur d'exécution 9 : L'indice n'appartient pas à la sélection".

Voici mon code :

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
24
25
26
27
28
29
30
31
 
Sub Impact_normes_IAS()
 
    Sheets("data").Select
 
    ' Supprimer toutes les données de A2:H65536
    Range("A2:J65536").Select
    Selection.ClearContents
 
     Dim DerniereLigne As Integer
     DerniereLigne = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("A65536").End(xlUp).Offset(1, 0)
 
 
     Workbooks.Open Filename:="P:\Non_Derivatives_P&L\Prod\Treso\Deals_du_jour\test.xls"
     Dim i As Integer
     Dim j As Integer
 
     For i = 2 To DerniereLigne
        j = i
        Range("a" & j) = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("a" & i)
        Range("b" & j) = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("b" & i)
        Range("c" & j) = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("c" & i)
        Range("d" & j) = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("d" & i)
        Range("e" & j) = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("e" & i)
        Range("f" & j) = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("f" & i)
        Range("g" & j) = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("g" & i)
        Range("h" & j) = Workbooks("test.xls").Worksheets("Impact_normes_IAS").Range("h" & i)
        i = i + 1
        Next i
 
End Sub
Pouvez-vous m'aider à résoudre ce problème?

Merci !