Bonjour,
Etant débutante en vba/excel j'ai ecrit cette macro qui remplie une feuille (Actions) par des champs récupérés d'une autre (GCBLO) selon une conditon: valeur d'une colonne dans la feuille Actions.
au moment de l'exécution, on m'affiche: erreur d'exécution1004: erreur définie par l'application ou par l'objet.
L'erreur vient de la ligne : If Sheets("Actions").Cells(j, 2) = "Commande FT" Then (quand je fais le débogage)
quelqu'un pourrait m'aider?
D'avance merci
ci dessous mon code
--
Option Explicit
Private Sub Worksheet_Activate()
' Mise a jour
Dim q As Long
Dim k, i, j As Long
Dim li As Long
q = Sheets("Actions").UsedRange.Rows.Count
For k = 7 To q
If Sheets("Actions").Cells(k, 2) = "Commande FT" Then
Sheets("Actions").Range(Cells(k, 5), Cells(k, 6)).ClearContents
Sheets("Actions").Range(Cells(k, 7), Cells(k, 10)).ClearContents
Sheets("Actions").Range(Cells(k, 11), Cells(k, 13)).ClearContents
End If
Next
' Remplissage automatique
li = Sheets("GCBLO").Range("B" & Rows.Count).End(xlUp).Row
j = 7
For i = 7 To li
If Sheets("Actions").Cells(j, 2) = "Commande FT" Then
Sheets("Actions").Cells(j, 6) = Sheets("GCBLO").Cells(i, 2)
Sheets("Actions").Cells(j, 7) = Sheets("GCBLO").Cells(i, 6)
Sheets("Actions").Cells(j, 5) = Sheets("GCBLO").Cells(i, 3) & " , " & Sheets("GCBLO").Cells(i, 4)
Sheets("Actions").Cells(j, 10) = Sheets("GCBLO").Cells(i, 7)
Sheets("Actions").Cells(j, 11) = Sheets("GCBLO").Cells(i, 8)
Sheets("Actions").Cells(j, 13) = Sheets("GCBLO").Cells(i, 10)
Sheets("Actions").Cells(j, 9) = Sheets("GCBLO").Cells(i, 9)
j = j + 1
Else: j = j + 1
i = i - 1
End If
Next
End Sub
Partager