Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
Anzeige
Archiv - Navigation
796to800
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
796to800
796to800
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

UserForm Eingabemaske Fehler

UserForm Eingabemaske Fehler
07.09.2006 14:42:00
Brunito
Hallo,
bei meiner Eingabemaske kommt immer der Fehler Laufzeitfehler 13 Typen unverträglich.
So sieht der Code aus:

Private Sub CommandButton1_Click()
UserForm2.Hide
End Sub


Private Sub CommandButton2_Click()
If ComboBox1.ListIndex > 0 Then
Rows(ComboBox1.ListIndex + 1).Delete
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
UserForm_Initialize
End If
End Sub


Private Sub CommandButton3_Click()
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
xZeile = [B65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 2) = TextBox1
Cells(xZeile, 3) = TextBox2
Cells(xZeile, 4) = TextBox3
Cells(xZeile, 5) = TextBox4
Cells(xZeile, 6) = TextBox5
Cells(xZeile, 8) = TextBox6
Cells(xZeile, 10) = TextBox7
Cells(xZeile, 12) = TextBox8
Cells(xZeile, 13) = TextBox9
Cells(xZeile, 16) = TextBox10
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
Columns("B:Q").Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub


Private Sub UserForm_Initialize()
Dim aRow, i As Variant
Application.EnableEvents = False
ComboBox1.Clear
aRow = [B65536].End(xlUp).Row
For i = 5 To aRow
ComboBox1.AddItem Cells(i, 1) & ", " & Cells(i, 2)
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub

Ich habe keine Ahnung, wo der Fehler liegen könnte.
Vielleicht hat von euch jemand eine Idee.
Gruß und Danke
Brunito

16
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: UserForm Eingabemaske Fehler
07.09.2006 15:05:53
Peter
Hallo Brunito,
mir kommt im Private Sub CommandButton2_Click() der Aufruf UserForm_Initialize nicht geheuer vor.
Schließe lieber dein UserForm(ular) mit Unload UserForm1 und öffne es neu mit UserForm1.Show, dann wird das Initialize auf jeden Fall durchlaufen.
Viele Grüße Peter
Eine kurze Nachricht, ob es läuft, wäre nett - danke.
AW: UserForm Eingabemaske Fehler
07.09.2006 15:25:59
Brunito
Hallo Peter,
läuft nicht!
Gruß
Brunito
AW: UserForm Eingabemaske Fehler
07.09.2006 15:52:23
Brunito
Hallo Peter,
habe diesen Fehler behoben. Es lag an UserForm_Initialize, muss heißen UserForm2_Initialize
Aber jetzt taucht das nächste Problem auf. Zum einen Zeigt mir die ComboBox nichts an, zum anderen, wenn ich die TextBox befülle kommt folgende Fehlermeldung:
Laufzeitfehler '1004'
Anwendungs- oder objektdefinierte Fehler
in der Zeile
Cells(xZeile, 2) = TextBox1
keine Ahznung, was das jetzt wieder bedeutet...
Gruß Brunito
Anzeige
AW: UserForm Eingabemaske Fehler
07.09.2006 15:56:23
Matthias
Hallo Brunito,
habe diesen Fehler behoben. Es lag an UserForm_Initialize, muss heißen UserForm2_Initialize
Das kann nicht sein. Du hast die Prozedur umbenannt, aber nun ist es keine Ereignisprozedur mehr, d.h. sie wird beim Laden der UF nicht mehr gestartet. Deshalb wird die Combobox auch nicht befüllt.
Gruß Matthias
AW: UserForm Eingabemaske Fehler
07.09.2006 16:00:38
Brunito
Hallo Matthias,
ändert es auch nichts daran, dass es sich um die UserForm2 handelt?
Das andere hat nicht funktioniert.
Gruß
Brunito
AW: UserForm Eingabemaske Fehler
07.09.2006 16:04:00
Matthias
Hallo Brunito,
der Name der Userform ist egal, es heiß immer Userform_Initialize(). Das sieht du oben im Codeblatt (in den Comoboxen links und rechts):
UserForm_Initialize():
Userform_________________________Initialize
UserForm2_Initialize():
(Allgemein)____________________UserForm2_Initialize
Gruß Matthias
Anzeige
AW: UserForm Eingabemaske Fehler
07.09.2006 16:10:59
Matthias
Hi,
jetzt hab ich die UF doch mal nachgebaut...
Der Fehler tritt auf, wenn beim Füllen der ComboBox in Spalte A oder B ein ehlerwert steht (z.B. #DIV/0!).

For i = 5 To aRow
ComboBox1.AddItem Cells(i, 1) & ", " & Cells(i, 2) 'wenn hier der Wert der Zellen ein Fehler ist, kommt Fehler 13.
Next i

Gruß Matthias
AW: UserForm Eingabemaske Fehler
07.09.2006 16:37:31
Brunito
Hallo Matthias,
das wars, vielen Dank. Die ComboBox wird jetzt befüllt!
Nur wenn ich jetzt die Textboxen befülle, tritt ein Fehler in der Zelle auf:
Columns("B:Q").Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Es wurde alles befüllt, aber in die 3. Zeile und nicht in die unterste Zeile, die frei ist.
Es tut mir leid wenn ich dich nerven sollte.
Bin dir aber sehr dankbar für deine Hilfe!
Gruß
Brunito
Anzeige
AW: UserForm Eingabemaske Fehler
07.09.2006 16:43:00
Matthias
Hallo Brunito,
lade mal eine Beispielmappe hoch.
Ich weiß ja eigentlich gar nicht, um was es in deiner Tabelle geht.
Gruß Matthias
AW: UserForm Eingabemaske Fehler
07.09.2006 17:25:47
Matthias
Hallo Brunito,
mit Columns("B:Q").Sort... sortierst Du auch den Tabellenkopf, welcher verbindene Zellen enthält.
Mein Vorschlag für CommandButton3_Click:

Private Sub CommandButton3_Click()
Dim xZeile As Long
Dim lZeile As Long '### NEU ###
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
xZeile = [B65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 2) = TextBox1
Cells(xZeile, 3) = TextBox2
Cells(xZeile, 4) = TextBox3
Cells(xZeile, 5) = TextBox4
Cells(xZeile, 6) = TextBox5
Cells(xZeile, 8) = TextBox6
Cells(xZeile, 10) = TextBox7
Cells(xZeile, 12) = TextBox8
Cells(xZeile, 13) = TextBox9
Cells(xZeile, 16) = TextBox10
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
lZeile = Cells(Rows.Count, 2).End(xlUp).Row '### NEU ###
' ### hier auch geändert: ###
Range("B5:Q" & lZeile).Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub

Gruß Matthias
Anzeige
AW: UserForm Eingabemaske Fehler
07.09.2006 18:35:02
Brunito
Hallo Matthias,
es läuft, Danke.
Zufrieden bin ich noch nicht ganz. Weil in den Textboxen nix angezeigt wird. Und der Command Button Clear funktioniert auch nicht.
Hier is der ganze Code

Private Sub ComboBox1_Click()
If ComboBox1.ListIndex <> 0 Then
TextBox1 = Cells(ComboBox1.ListIndex + 1, 2)
TextBox2 = Cells(ComboBox1.ListIndex + 1, 3)
TextBox3 = Cells(ComboBox1.ListIndex + 1, 4)
TextBox4 = Cells(ComboBox1.ListIndex + 1, 5)
TextBox5 = Cells(ComboBox1.ListIndex + 1, 6)
TextBox6 = Cells(ComboBox1.ListIndex + 1, 8)
TextBox7 = Cells(ComboBox1.ListIndex + 1, 10)
TextBox8 = Cells(ComboBox1.ListIndex + 1, 12)
TextBox9 = Cells(ComboBox1.ListIndex + 1, 13)
TextBox10 = Cells(ComboBox1.ListIndex + 1, 17)
Else
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
End If
End Sub


Private Sub CommandButton1_Click()
Unload UserForm2
End Sub


Private Sub CommandButton2_Click()
If ComboBox1.ListIndex > 0 Then
Rows(ComboBox1.ListIndex + 1).Delete
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
UserForm_Initialize
End If
End Sub


Private Sub CommandButton3_Click()
Dim xZeile As Long
Dim lZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
xZeile = [B65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 2) = TextBox1
Cells(xZeile, 3) = TextBox2
Cells(xZeile, 4) = TextBox3
Cells(xZeile, 5) = TextBox4
Cells(xZeile, 6) = TextBox5
Cells(xZeile, 8) = TextBox6
Cells(xZeile, 10) = TextBox7
Cells(xZeile, 12) = TextBox8
Cells(xZeile, 13) = TextBox9
Cells(xZeile, 17) = TextBox10
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
lZeile = Cells(Rows.Count, 5).End(xlUp).Row
Range("B5:Q" & lZeile).Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub


Private Sub UserForm_Initialize()
Dim aRow, i As Variant
Application.EnableEvents = False
ComboBox1.Clear
aRow = [B65536].End(xlUp).Row
'ComboBox1.AddItem "neue Person hinzufügen"
For i = 5 To aRow
ComboBox1.AddItem Cells(i, 2) & ", " & Cells(i, 3)
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub

Und eine Beispiel datei, wo es funktioniert.
https://www.herber.de/bbs/user/36493.xls
Gruß Brunito
Anzeige
@Matthias
07.09.2006 18:49:02
Brunito
Hallo Matthias,
habs hinbekommen!!! Bitte schau es dir nicht mehr durch.
Nochmal vielen Dank für deine Hilfe und Geduld, ohne dich hätte ich es nicht hinbekommen.
Gruß
Brunito
AW: UserForm Eingabemaske Fehler
07.09.2006 15:06:10
Matthias
Hallo Brunito,
wichtig wäre doch, wo der Fehler auftaucht. In welcher Zeile?
Gruß Matthias
AW: UserForm Eingabemaske Fehler
07.09.2006 15:29:03
Brunito
Hallo Matthias,
wenn ich es jetzt laufen lassen will, kommt der Fehler sofort.
Aber am Anfang, war es bei UserForm_Initialize
Dim aRow, i As Variant
Zumindest glaub ich das.
Gruß
Brunito
AW: UserForm Eingabemaske Fehler
07.09.2006 15:39:51
Matthias
Hallo Brunito,
Zumindest glaub ich das.
setze mit F9 einen Haltepunkt zum Beginn der Userform_Initialize()-Prozedur.
Dann mit F8 Einzelschritt bis zum Aufteten des Fehlers.
Gruß Matthias
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige