AW: Textbox und Format in Zell
04.07.2011 19:30:35
Franz
Hallo Christian,
habs versucht geht aber nicht. Ich häng mal den Code an vieleicht sehe ich den Wald vor lauter Bäumen nicht .
Danke für deine Hilfe#
Private Sub CommandButton1_Click()
Dim lLetzte As Long
Dim iIndex As Integer
If TextBox1.Value = "" Then
MsgBox "Sie müssen eine Artikel Nr.: eingeben - danke.", _
48, " Hinweis für " & Application.UserName
TextBox1.SetFocus
Exit Sub
End If
If TextBox2.Value = "" Then
MsgBox "Sie müssen einen Artikeltext eingeben - danke.", _
48, " Hinweis für " & Application.UserName
TextBox2.SetFocus
'Exit Sub
End If
strtxt = TextBox1
If Len(strtxt) = 6 Then
strtxt = "P-" & Left(strtxt, 2) & "-" & Mid(strtxt, 3, 2) & "-" & Right(strtxt, 2)
Sheets("Tabelle1").Cells(1, 1) = strtxt
End If
'If TextBox3.Value = "" Then
' MsgBox "Sie müssen einen Straßennamen eingeben - danke.", _
' 48, " Hinweis für " & Application.UserName
' TextBox3.SetFocus
' Exit Sub
'End If
'If TextBox4.Value = "" Then
' MsgBox "Sie müssen eine Postleitzahl eingeben - danke.", _
' 48, " Hinweis für " & Application.UserName
' TextBox4.SetFocus
' Exit Sub
'ElseIf Len(TextBox4.Value) 5 Then
' MsgBox "Sie müssen eine 5-stellige Postleitzahl eingeben - danke.", _
' 48, " Hinweis für " & Application.UserName
' TextBox4.SetFocus
' Exit Sub
'End If
'If TextBox5.Value = "" Then
' MsgBox "Sie müssen einen Ortsnamen eingeben - danke.", _
' 48, " Hinweis für " & Application.UserName
' TextBox5.SetFocus
' Exit Sub
'End If
'If TextBox7.Value = "" Then
' MsgBox "Sie müssen eine Telefonnummer eingeben - danke.", _
' 48, " Hinweis für " & Application.UserName
' TextBox7.SetFocus
' Exit Sub
'End If
' die Daten sind geprüft und können in die Tabelle eingetragen werden
Application.ScreenUpdating = False
With Worksheets("Bestand")
'.Unprotect Password:="Geheim"
lLetzte = IIf(.Range("A65536") "", 65536, .Range("A65536").End(xlUp).Row) + 1
If lLetzte "" Then
' If IsDate(TextBox6.Value) Then
.Range("F" & lLetzte).Value = TextBox6.Value
' ElseIf IsDate(Left(TextBox6.Value, Len(TextBox6.Value) - 3)) Then
' .Range("F" & lLetzte).Value = Format(TextBox6.Value, "dd.mm.yyyy ddd")
' End If
'End If
.Range("G" & lLetzte).Value = TextBox7.Value
' Tabelle nach "Artikel nr.:", "Artikeltext", "Lagerplatz" sortieren
.Range(.Cells(1, 1), .Cells(lLetzte, 7)).Sort _
Key1:=.Cells(1, 1), Order1:=xlAscending, _
Key2:=.Cells(1, 2), Order2:=xlAscending, _
Key3:=.Cells(1, 4), Order3:=xlAscending, _
Header:=xlGuess
.Columns("A:G").EntireColumn.AutoFit
Call Zeilen_faerben
With ListBox1
Call Array_fuellen
.Clear
.Column = aTmp
End With
Label8.Caption = "Anzahl Artikel-Einträge: " & (lLetzte - 1)
'.Protect Password:="Geheim"
End With
For iIndex = 1 To 7
With Controls("TextBox" & iIndex)
.Value = ""
End With
Next iIndex
Application.ScreenUpdating = True
'End If
End Sub