'allgemeines Modul
Sub CreateInputboxBarZahlende()
'Menüleiste mit Textfeld und Button zum Ausführen
Dim oBar As CommandBar
Dim oCombo As CommandBarControl
Dim oBtn As CommandBarButton
DeleteInputboxBarZahlende
With Application.CommandBars.Add(Name:="Zahlende")
.Visible = True
.Position = msoBarFloating
Set oCombo = .Controls.Add(Type:=msoControlEdit, Temporary:=True)
Set oBtn = .Controls.Add(Type:=msoControlButton, Temporary:=True)
End With
With oCombo
.OnAction = "addieren"
.Width = 50
End With
With oBtn
.Caption = "Zahlend"
.OnAction = "addieren"
.Style = msoButtonIconAndCaption
.FaceId = 137
End With
End Sub
Private Sub addieren()
Dim ziffer As Integer
ziffer = Application.CommandBars("Zahlende").Controls(1).Text
' If ziffer = 0 Or Empty Then Exit Sub
' in Gästeliste ist e166 der Altbestand der Gäste, e168 der Neubestand der Gäste nach Eingabe
If ziffer >= 0 Then
Range("G167").Select
ActiveCell.FormulaR1C1 = ziffer
Range("G167").Select
Selection.Insert Shift:=xlDown
Sheets("Gästeliste").Range("e166") = Sheets("Gästeliste").Range("e167")
Sheets("Gästeliste").Range("e167") = Sheets("Gästeliste").Range("e166") + ziffer
' Application.CommandBars("Zahlende addieren").Controls(1).Clear
End If
End Sub
Sub DeleteInputboxBarZahlende()
On Error Resume Next
Application.CommandBars("Zahlende").Delete
End Sub