Plantage code suite à rows.insert
Bonjour.
Au sujet de la discussion : ROWS.INSERT probléme macro plante
J'ai actuellement le même genre de problème sur un programme vba excel 2010 sur lequel je travail.
Je fais une boucle pour lire un tableau sur la feuille 1, puis en fonction de ce que contient la ligne lu, je vais copier une ligne de la feuille 2 puis insérer cette dernière à la fin de la feuille.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
For i = 12 To derniere_ligne
If Worksheets("Referentiel").Range("J" & i) = "Oui" And Worksheets("Referentiel").Range("A" & i) <> "" Then
Debug.Print Worksheets("Referentiel").Range("C" & i)
If InStr(Worksheets("Referentiel").Range("A" & i), "/") <> 0 Then
Worksheets("Cartographie").Rows(18).Copy
Else
Worksheets("Cartographie").Rows(17).Copy
End If
Debug.Print "Avant Insert row " & current_row_index
Worksheets("Cartographie").Rows(current_row_index).Insert
Debug.Print "Apres Insert row " & current_row_index
Worksheets("Cartographie").Range("A" & current_row_index) = Worksheets("Referentiel").Range("A" & i)
Worksheets("Cartographie").Range("B" & current_row_index) = Worksheets("Referentiel").Range("C" & i)
Worksheets("Cartographie").Range("C" & current_row_index) = Worksheets("Referentiel").Range("E" & i)
current_row_index = current_row_index + 1
Worksheets("Cartographie").Application.CutCopyMode = False
End If
Next i |
Ce code plante parfois à la ligne où je fais le Insert et je n'arrive pas à savoir pourquoi.
Avez vous trouvé une solution ?