AW: Userform - Mehrfacheingaben in Textboxen
20.07.2015 15:30:06
Herbert
Hallo Uli,
so, nun habe ich die Lösung. Ich habe es ein wenig überarbeitet, denn innerhalb eines Projektes braucht man ja nicht immer wieder in das Feld "Wohnungen im Projekt" zu springen. Dorthin springt der Cursor erst beim Projektwechsel. Also bitte aufgepasst!
Kopiere bitte den gesamten u. a. Code in Deine UF, bitte wirklich alles!
Option Explicit
Public ProjCount%, WhgCount%
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub CommandButton1_Click()
Dim letzteZeile%, AnzahlProj%, AnzahlWhg%
AnzahlProj = Me.TextBox2 * 1
AnzahlWhg = Me.TextBox3 * 1
If ProjCount = 0 Then ProjCount = 1
WhgCount = WhgCount + 1
With Sheets(1)
letzteZeile = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(letzteZeile, 1) = Me.TextBox1 '* Vermieter
.Cells(letzteZeile, 2) = ProjCount '* Projekt-Nr.
.Cells(letzteZeile, 3) = "?"
.Cells(letzteZeile, 4) = WhgCount '* Whg-Nr.
.Cells(letzteZeile, 5) = Me.TextBox4
.Cells(letzteZeile, 6) = Me.TextBox5
.Cells(letzteZeile, 7) = Me.TextBox6
End With
If WhgCount >= AnzahlWhg Then
If ProjCount >= AnzahlProj Then
Me.Hide
Unload Me
WhgCount = 0
ProjCount = 0
AnzahlProj = 0
AnzahlWhg = 0
GoTo ende
End If
ProjCount = ProjCount + 1
Me.TextBox2.Enabled = False
Me.TextBox3.Enabled = True
Me.fra1.Caption = "Wohnung Nr. " & WhgCount + 1
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox3.SetFocus
WhgCount = 0
Else
Me.TextBox2.Enabled = False
Me.TextBox3.Enabled = False
Me.fra1.Caption = "Wohnung Nr. " & WhgCount + 1
TextBox4 = ""
TextBox5 = ""
TextBox4.SetFocus
End If
ende:
End Sub
Probier's mal und gib mir bitte kurz Bescheid.
Servus