Hallo Werner.
vielen Dank, habe es jetzt etwas einfacher gelöst und es funktioniert bis jetzt soweit. Vielleicht fällt dir ja trotzdem ein gravierender Fehler im Code auf und man kann es doch nicht so machen, wie ich es gelöst habe!? Dann könntest du eventuell bitte Bescheid geben!?
Meine Lösung:
Private Sub cmd_Simultanität_aus_Click()
ActiveSheet.Unprotect Password:=""
Dim rngAuswahl As Range
Dim c As Object
Set rngAuswahl = Application.InputBox("Bitte den Bereich markieren, dessen Simultanität geändert werden soll.", Type:=8)
If rngAuswahl.Rows.Count > 1 Then
MsgBox "Bitte wählen Sie nur ein Equipment / eine Anlage aus.", vbCritical
Exit Sub
End If
For Each c In rngAuswahl.Cells
If IsNumeric(c.Value) And Not IsEmpty(c.Value) Then
If Cells(c.Row, 7).Value <> "x" Then
MsgBox "Bitte wählen Sie erst die gesamte Zeile simultan.", vbCritical
Exit Sub
End If
If c.Font.ColorIndex <> 16 Then
ActiveSheet.Unprotect Password:=""
c.Font.ColorIndex = 16
If c.Column = 8 Then
c.Offset(0, 1).Resize(1, 2).Font.ColorIndex = 16
End If
Range("A6").Value = "Gebäude"
GoTo 1
End If
If c.Font.ColorIndex = 16 Then
ActiveSheet.Unprotect Password:=""
c.Font.ColorIndex = xlAutomatic
If c.Column = 8 Then
c.Offset(0, 1).Resize(1, 2).Font.ColorIndex = xlAutomatic
End If
Range("A6").Value = "Gebäude"
End If
End If
1:
Next c
End Sub
|