Private
Function
CheckMissingValues(ws
As
Worksheet)
As
Boolean
Dim
lastRow
As
Long
Dim
i
As
Long
Dim
j
As
Long
lastRow = ws.Cells(ws.Rows.Count,
"A"
).
End
(xlUp).Row
For
i = 1
To
lastRow
If
ws.Cells(i,
"A"
).Value <>
""
Then
For
j = 2
To
8
If
ws.Cells(i, j).Value =
""
Then
CheckMissingValues =
True
Exit
Function
End
If
Next
j
End
If
Next
i
CheckMissingValues =
False
End
Function
Private
Sub
Workbook_BeforeSave(
ByVal
SaveAsUI
As
Boolean
, Cancel
As
Boolean
)
Dim
ws
As
Worksheet
Set
ws = ThisWorkbook.Sheets(1)
If
CheckMissingValues(ws)
Then
MsgBox
"Es gibt mindestens eine leere Zeile, in den Spalten B bis H, obwohl in Spalte A ein Wert ist. Bitte korrigieren, bevor die Datei gespeichert wird."
, vbExclamation,
"Warnung"
Cancel =
True
End
If
End
Sub