ich erstelle mir gerade ein klines Büchlein interessanter Code-Schnippsel. Dabei habe ich einen Schnippsel gefunden der aber irgendwie nicht läuft. Weiß jemand Rat ?
bedanke mich schonmal vorweg.
Wenn Checkbox 1 angeklickt wird, sollen sich in den Zellen C1:J1 und L1:P1 die Schriftfarbe ändern.
dieser Code gehört in die Checkbox
Private Sub CheckBox1_Click()
If CheckBox1 Then
'1 steht für den Namen der Checkbox
'bzw. kennzeichnet ja auch die Zeile
Colour_Cells (1)
Else
UnColour_Cells (1)
End If
End Sub
Dieser Code gehört in ein Modul:Sub Colour_Cells(myR As Integer)
' myR für die Zeile wird von der Checkbox übergeben
' 4 und 8 kennzeichnen die Spalten die du markieren willst
With Range(Cells(myR, 4), Cells(myR, 8))
.Interior.ColorIndex = 3 '3 = Rot
'Die Rahmen kannst du ja anpassen
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End With
End Sub Sub UnColour_Cells(myR As Integer)
With Range(Cells(myR, 4), Cells(myR, 8))
.Interior.ColorIndex = 6 ' 6 = Gelb
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub