habe folgendes Problem:
In einer Userform habe ich mehrere Textboxen in die ich Zahlen eingebe. Ich möchte das wenn ich 1,7 eingebe 1,70 angezeigt wird.
Gruß Ralph
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Format(TextBox1, "0.00")
End Sub
Range("A1") = TextBox1 * 1 'Mal 1 nehmen
Range("A3") = CDbl(TextBox1)
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Format(TextBox1, "0.00")
Range("A3") = CDbl(TextBox1)
End Sub
Sub Umsatz_Buchen(TNr As Long)
'Dieses Makro dient der Eingabe der Buchung ueber eine Userform und schreibt die Eingabe in das _
Blatt fuer den Tisch
Dim MySh As Worksheet
Dim TLastRow As Long
Application.ScreenUpdating = False
UF1.LB_Datum = Date
UF1.LB_Gast = ThisWorkbook.Sheets("Tischplan").Cells(TNr + 1, 2).Value
UF1.LB_Tisch = TNr
UF1.Show
If UserSel = "abbruch" Then
Unload UF1
Exit Sub
End If
'pruefen, ob Blatt fuer tisch schon vorhanden, ansonsten anlegen
UserSel = ""
For Each MySh In ThisWorkbook.Sheets
If MySh.Name = UF1.LB_Tisch.Caption Then
UserSel = "Blatt vorhanden"
Exit For
End If
Next MySh
If UserSel = "" Then
ThisWorkbook.Sheets("Tisch_Vorlage").Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets. _
Count)
ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Name = UF1.LB_Tisch.Caption
ThisWorkbook.Sheets("" & UF1.LB_Tisch.Caption).Visible = True
End If
'Werte aus Userform uebernehmen
Set TargetSh = ThisWorkbook.Sheets("" & UF1.LB_Tisch.Caption)
With TargetSh
'finde letzte Zeile in Tischblatt
UserSel = ""
TLastRow = .Range(.Cells(.Rows.Count, 1).Address).End(xlUp).Row
If UF1.TB_Produkt1.Value "" Then
UserSel = "zeile vorhanden"
.Cells(TLastRow + 1, 1).Value = UF1.TB_Produkt1.Value
End If
If UF1.TB_Menge1.Value "" Then
.Cells(TLastRow + 1, 2).Value = UF1.TB_Menge1.Value
End If
If UF1.TB_Preis1.Value "" Then
.Cells(TLastRow + 1, 3).Value = UF1.TB_Preis1.Value
End If
If UF1.TB_Gesamt1.Value "" Then
.Cells(TLastRow + 1, 4).Value = UF1.TB_Gesamt1.Value
End If
If UserSel = "zeile vorhanden" Then
.Cells(TLastRow + 1, 5).Value = UF1.LB_Gast.Caption
.Cells(TLastRow + 1, 6).Value = UF1.LB_Datum.Caption
TLastRow = TLastRow + 1
UserSel = ""
End If
If UF1.TB_Produkt2.Value "" Then
UserSel = "zeile vorhanden"
.Cells(TLastRow + 1, 1).Value = UF1.TB_Produkt2.Value
End If
If UF1.TB_Menge2.Value "" Then
.Cells(TLastRow + 1, 2).Value = UF1.TB_Menge2.Value
End If
If UF1.TB_Preis2.Value "" Then
.Cells(TLastRow + 1, 3).Value = UF1.TB_Preis2.Value
End If
If UF1.TB_Gesamt2.Value "" Then
.Cells(TLastRow + 1, 4).Value = UF1.TB_Gesamt2.Value
End If
If UserSel = "zeile vorhanden" Then
.Cells(TLastRow + 1, 5).Value = UF1.LB_Gast.Caption
.Cells(TLastRow + 1, 6).Value = UF1.LB_Datum.Caption
TLastRow = TLastRow + 1
UserSel = ""
End If
If UF1.TB_Produkt3.Value "" Then
UserSel = "zeile vorhanden"
.Cells(TLastRow + 1, 1).Value = UF1.TB_Produkt3.Value
End If
If UF1.TB_Menge3.Value "" Then
.Cells(TLastRow + 1, 2).Value = UF1.TB_Menge3.Value
End If
If UF1.TB_Preis3.Value "" Then
.Cells(TLastRow + 1, 3).Value = UF1.TB_Preis3.Value
End If
If UF1.TB_Gesamt3.Value "" Then
.Cells(TLastRow + 1, 4).Value = UF1.TB_Gesamt3.Value
End If
If UserSel = "zeile vorhanden" Then
.Cells(TLastRow + 1, 5).Value = UF1.LB_Gast.Caption
.Cells(TLastRow + 1, 6).Value = UF1.LB_Datum.Caption
TLastRow = TLastRow + 1
UserSel = ""
End If
If UF1.TB_Produkt4.Value "" Then
UserSel = "zeile vorhanden"
.Cells(TLastRow + 1, 1).Value = UF1.TB_Produkt4.Value
End If
If UF1.TB_Menge4.Value "" Then
.Cells(TLastRow + 1, 2).Value = UF1.TB_Menge4.Value
End If
If UF1.TB_Preis4.Value "" Then
.Cells(TLastRow + 1, 3).Value = UF1.TB_Preis4.Value
End If
If UF1.TB_Gesamt4.Value "" Then
.Cells(TLastRow + 1, 4).Value = UF1.TB_Gesamt4.Value
End If
If UserSel = "zeile vorhanden" Then
.Cells(TLastRow + 1, 5).Value = UF1.LB_Gast.Caption
.Cells(TLastRow + 1, 6).Value = UF1.LB_Datum.Caption
TLastRow = TLastRow + 1
UserSel = ""
End If
If UF1.TB_Produkt5.Value "" Then
UserSel = "zeile vorhanden"
.Cells(TLastRow + 1, 1).Value = UF1.TB_Produkt5.Value
End If
If UF1.TB_Menge5.Value "" Then
.Cells(TLastRow + 1, 2).Value = UF1.TB_Menge5.Value
End If
If UF1.TB_Preis5.Value "" Then
.Cells(TLastRow + 1, 3).Value = UF1.TB_Preis5.Value
End If
If UF1.TB_Gesamt5.Value "" Then
.Cells(TLastRow + 1, 4).Value = UF1.TB_Gesamt5.Value
End If
If UserSel = "zeile vorhanden" Then
.Cells(TLastRow + 1, 5).Value = UF1.LB_Gast.Caption
.Cells(TLastRow + 1, 6).Value = UF1.LB_Datum.Caption
TLastRow = TLastRow + 1
UserSel = ""
End If
If UF1.TB_Produkt6.Value "" Then
UserSel = "zeile vorhanden"
.Cells(TLastRow + 1, 1).Value = UF1.TB_Produkt6.Value
End If
If UF1.TB_Menge6.Value "" Then
.Cells(TLastRow + 1, 2).Value = UF1.TB_Menge6.Value
End If
If UF1.TB_Preis6.Value "" Then
.Cells(TLastRow + 1, 3).Value = UF1.TB_Preis6.Value
End If
If UF1.TB_Gesamt6.Value "" Then
.Cells(TLastRow + 1, 4).Value = UF1.TB_Gesamt6.Value
End If
If UserSel = "zeile vorhanden" Then
.Cells(TLastRow + 1, 5).Value = UF1.LB_Gast.Caption
.Cells(TLastRow + 1, 6).Value = UF1.LB_Datum.Caption
TLastRow = TLastRow + 1
UserSel = ""
End If
If UF1.TB_Produkt7.Value "" Then
UserSel = "zeile vorhanden"
.Cells(TLastRow + 1, 1).Value = UF1.TB_Produkt7.Value
End If
If UF1.TB_Menge7.Value "" Then
.Cells(TLastRow + 1, 2).Value = UF1.TB_Menge7.Value
End If
If UF1.TB_Preis7.Value "" Then
.Cells(TLastRow + 1, 3).Value = UF1.TB_Preis7.Value
End If
If UF1.TB_Gesamt7.Value "" Then
.Cells(TLastRow + 1, 4).Value = UF1.TB_Gesamt7.Value
End If
If UserSel = "zeile vorhanden" Then
.Cells(TLastRow + 1, 5).Value = UF1.LB_Gast.Caption
.Cells(TLastRow + 1, 6).Value = UF1.LB_Datum.Caption
TLastRow = TLastRow + 1
UserSel = ""
End If
End With
ThisWorkbook.Sheets("Tische").Select
Application.ScreenUpdating = True
MsgBox "Umsatz fuer Tisch " & UF1.LB_Tisch.Caption & " gebucht.", 64, "Information"
'loesche userform
Unload UF1
End Sub
If UF1.TB_Preis1.Value "" Then
.Cells(TLastRow + 1, 3).Value = CDbl(UF1.TB_Preis1.Value)
End If