Private
Sub
abbrechenButton_Click()
Unload UserForm1
End
Sub
Private
Sub
saveButton1_Click()
Dim
strBlattName
As
String
strBlattName =
"Protokollierung"
On
Error
Resume
Next
Worksheets(strBlattName).Activate
If
Err.Number <> 0
Then
Err.Clear
MsgBox
"Blatt ["
& strBlattName &
"] nicht vorhanden! Wird automatisch angelegt!"
Worksheets.Add
ActiveSheet.Name =
"Protokollierung"
ActiveSheet.Move After:=Sheets(Sheets.Count)
Range(
"A1:D1"
).Font.Bold =
True
Range(
"A1:D1"
).Interior.ColorIndex = 8
Range(
"A1"
).Value =
"Name"
Range(
"B1"
).Value =
"Datum"
Range(
"C1"
).Value =
"Zeit"
Range(
"D1"
).Value =
"Kommentar"
Columns(
"D:D"
).ColumnWidth = 70
Worksheets(
"Protokollierung"
).Range(
"A2"
) = NameBox1
Worksheets(
"Protokollierung"
).Range(
"B2"
) = DatumBox1
Worksheets(
"Protokollierung"
).Range(
"C2"
) = TimeBox1
Worksheets(
"Protokollierung"
).Range(
"D2"
) = Commend
ThisWorkbook.Save
MsgBox
"Änderungen gespeichert und protokolliert."
ThisWorkbook.Close
Else
Worksheets(strBlattName).Activate
Rows(
"2:2"
).
Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range(
"A3:D3"
).
Select
Selection.Copy
Range(
"A2:D2"
).
Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=
False
, Transpose:=
False
Application.CutCopyMode =
False
Worksheets(
"Protokollierung"
).Range(
"A2"
) = NameBox1
Worksheets(
"Protokollierung"
).Range(
"B2"
) = DatumBox1
Worksheets(
"Protokollierung"
).Range(
"C2"
) = TimeBox1
Worksheets(
"Protokollierung"
).Range(
"D2"
) = Commend
ThisWorkbook.Save
MsgBox
"Änderungen gespeichert und protokolliert."
ThisWorkbook.Close
End
If
End
Sub
Private
Sub
UserForm_Initialize()
With
UserForm1.NameBox1
.AddItem
"Eberle"
.AddItem
"Müller"
.AddItem
".."
.AddItem
".."
End
With
UserForm1.DatumBox1.Value =
Date
UserForm1.TimeBox1.Value = Time
End
Sub