Sicuramente avrò sbagliato qualcosa ma non succede niente


Private Sub QueryTable_AfterRefresh(Success As Boolean)
MsgBox "evento attivato"

If Success
MsgBox "query riuscita"
Set Range_Dati = Range("d2:d10")
Set Foglio_Appoggio = Worksheets("FoglioAppoggio")

Rosso = RGB(255, 70, 94)
Giallo = RGB(255, 243, 102)
Verde = RGB(0, 242, 61)

For Each Casella In Range_Dati
If Casella > Foglio_Appoggio.Cells(Casella.Row, Casella.Column) Then
Casella.Interior.Color = Verde
ElseIf Casella = Foglio_Appoggio.Cells(Casella.Row, Casella.Column) Then
Casella.Interior.Color = Giallo
Else
Casella.Interior.Color = Rosso
End If
Foglio_Appoggio.Cells(Casella.Row, Casella.Column) = Casella
Next

End If
End Sub