Probleme #VALEUR lors du coloriage d'une cellule
Voici ma macro, qui fonctoinne très bien sauf lorsque j'ai rajouté le coloriage d'une cellule, la macro na plus marché et affiche #VALEUR. Lorsque je met en comentaire la ligne ou je colore la cellule, la macro remarche.
Code:
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 32 33 34 35
| Function aurore(ByVal Nombre_de_chiffre As Integer, ByVal Numero_du_compte As String)
Dim test As String
Dim j As Integer
Dim i As Integer
Dim somme As Long
Dim numColonne As Integer
somme = 0
For j = 1 To 20
If Worksheets(2).Cells(1, j).Value = "SOLDE" Then
numColonne = j
End If
Next
For i = 1 To 200
test = Mid(Worksheets(2).Cells(i, 1).Value, 1, Nombre_de_chiffre)
If test = Numero_du_compte Then
somme = somme + Worksheets(2).Cells(i, numColonne).Value
End If
If test = Numero_du_compte Then
Worksheets(2).Cells(i, numColonne).Interior.Color = RGB(200, 200, 200)
End If
Next
resultat = somme
aurore = resultat
End Function |
D'ou ma question, qqn peut il me dire pkoi cette ligne
Worksheets(2).Cells(i, numColonne).Interior.Color = RGB(200, 200, 200)
ait -elle planté toute ma macro.
Merci