If Cells(e, 7).Interior.ColorIndex = 6 funktioniert aber bei
If Cells(e, 7).Interior.ColorIndex = a geht nichts, sobald ich eine Variable nehme streikt mein VBA.
Woran liegt das?
Sub Schaltfläche1_Klicken()
Dim a As Long
a = Cells(1, 1).Interior.ColorIndex
If Cells(1, 1).Interior.ColorIndex = a Then
MsgBox "Zelle A1 hat den ColorIndex " & a
End If
End Sub
Zelle A1 färben und Code laufen lassen.Sub Schaltfläche1_Klicken()
Dim a As Long
a = 3 'ColorIndex für rot = 3
If Cells(1, 1).Interior.ColorIndex = a Then
MsgBox "Zelle A1 hat den ColorIndex " & a
Else
MsgBox "Zelle A1 hat eine andere Farbe als rot"
End If
End Sub
Gruß Werner