Sub
SetXForStabchen()
Dim
ws
As
Worksheet
Dim
cell
As
Range
Dim
currentRowColor
As
Long
Dim
currentCellColor
As
Long
Dim
belowRowColor
As
Long
Dim
whiteColor
As
Long
Dim
greenColor
As
Long
Dim
lastRow
As
Long
Dim
rowIndex
As
Long
Dim
colIndex
As
Long
Set
ws = ThisWorkbook.Sheets(
"Tabelle1"
)
whiteColor = RGB(255, 255, 255)
greenColor = RGB(0, 255, 0)
lastRow = ws.Cells(ws.Rows.Count, 1).
End
(xlUp).Row
For
Each
cell
In
Selection
rowIndex = cell.Row
colIndex = cell.Column
currentCellColor = cell.Interior.Color
If
rowIndex
Mod
2 = 1
Then
currentRowColor = greenColor
Else
currentRowColor = whiteColor
End
If
If
rowIndex < lastRow
Then
belowRowColor = ws.Cells(rowIndex + 1, colIndex).Interior.Color
Else
belowRowColor = RGB(255, 255, 255)
End
If
If
currentRowColor = whiteColor
And
currentCellColor = greenColor
And
belowRowColor = whiteColor
Then
cell.Offset(-1, 0).Value =
"X"
ElseIf
currentRowColor = greenColor
And
currentCellColor = whiteColor
And
belowRowColor = greenColor
Then
cell.Offset(-1, 0).Value =
"X"
End
If
Next
cell
End
Sub