| VBA-Beispiel 048 | |
|
|
|
vba / mit Blattschutz Eingaben schützen |
|
|
Nachdem in Zeile 2 (Überschriften sind in Zeile 1) Eingaben gemacht wurden, wird diese Zeile vor dem Überschreiben geschützt. Danach sind Eingaben nur in Zeile 3 möglich ... Maximal können 5 Zeilen beschrieben werden. |
|
|
Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Application.Intersect(Target, Range("E2:E6")) _ Is Nothing Then Call Schutz_2 End Sub Sub Schutz_2() Dim Zeile As Long Sheets("Tabelle2").Unprotect Password:="bla" For Zeile = 2 To 5 If Cells(Zeile, 5).Locked = False Then Range(Cells(Zeile, 1), Cells(Zeile, 5)).Locked = True Range(Cells(Zeile, 1), Cells(Zeile, 5)).Interior.ColorIndex = xlNone Range(Cells(Zeile + 1, 1), Cells(Zeile + 1, 5)).Locked = False Range(Cells(Zeile + 1, 1), Cells(Zeile + 1, 5)).Interior.ColorIndex = 35 Cells(Zeile + 1, 5).Interior.ColorIndex = 45 Sheets("Tabelle2").Protect Password:="bla" Exit Sub End If Next Zeile Cells.Interior.ColorIndex = xlNone Range(Cells(1, 1), Cells(1, 5)).Interior.ColorIndex = 6 Cells.Locked = True Sheets("Tabelle2").Protect Password:="bla" MsgBox "keine weitere Eingabe möglich", , "Tabelle gesperrt" End Sub |
|
|
Download: vba048.zip |
|
|
relevante Links: |
|
| |