Habe unten Formel für Berechnung wenn Optionsfeld zb.Montag aktiviert wird.Funktioniert auch,aber man kann nur ein Optionsfeld aktivieren.
Habe 5 Optionsfelder " Mo bis Fr." Müsste die Formel aber auch berechnen lassen wenn bis zu alle 5 Optionsfelder aktiviert werden.
Sub pause_akt_Z()
Dim wt As Byte, i%, x As Byte, optB$
Dim sh As Worksheet
Dim sh1 As Worksheet
Set sh = Worksheets("blatt")
Set sh1 = Worksheets("Legende")
For x = 1 To 5
If sh1.OLEObjects(x).Object = True Then
optB = sh1.OLEObjects(x).Name
End If
Next
i = ActiveCell.Row
wt = Weekday(sh.Cells(i, 2))
Select Case optB
Case "OptionButton1"
If wt = 2 Then
Range(sh.Cells(i, 4), sh.Cells(i, 5)) = ""
Else
sh.Cells(i, 4) = 11#
sh.Cells(i, 5) = 11.5
End If
Case "OptionButton2"
If wt = 3 Then
Range(sh.Cells(i, 4), sh.Cells(i, 5)) = ""
Else
sh.Cells(i, 4) = 11#
sh.Cells(i, 5) = 11.5
End If
Case "OptionButton3"
If wt = 4 Then
Range(sh.Cells(i, 4), sh.Cells(i, 5)) = ""
Else
sh.Cells(i, 4) = 11#
sh.Cells(i, 5) = 11.5
End If
Case "OptionButton4"
If wt = 5 Then
Range(sh.Cells(i, 4), sh.Cells(i, 5)) = ""
Else
sh.Cells(i, 4) = 11#
sh.Cells(i, 5) = 11.5
End If
Case "OptionButton5"
If wt = 6 Then
Range(sh.Cells(i, 4), sh.Cells(i, 5)) = ""
Else
sh.Cells(i, 4) = 11#
sh.Cells(i, 5) = 11.5
End If
End Select
End Sub