Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1252to1256
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
Inhaltsverzeichnis

Laufzeitfehler 9 beim UserForm eingabe

Laufzeitfehler 9 beim UserForm eingabe
Fabian
Hallo Zusammen
Ich habe ein kleines Problem - die Kollegen von hier konnten mir schon viel weiterhelfen hier also versuche ich es nochmals da ;-)
Ich habe ein UserForm -welches Daten in verschiedene Spalten schreibt.
Jetzt beanstandet VBA aber einen Laufzeitfehler 9 (Index ausserhalb des gültigen Bereichs) und zwar in Zeile 4. Das File heisst tatsächlich "Datenquelle_Titel".
Könnt Ihr mir sagen wieso das er diese Fehlermeldung ausspuckt
Anbei der code:
rivate

Sub CommandButton1_Click()
Dim lz As Long
Dim shMain As Worksheet
Set shMain = ThisWorkbook.Sheets("Datenquelle_Titel")
With shMain
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 2) = Me.TextBox1
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 3) = Me.TextBox2
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 4) = Me.TextBox3
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 5) = Me.TextBox4
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 53) = Me.TextBox19
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 54) = Me.TextBox18
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 55) = Me.TextBox17
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 56) = Me.TextBox16
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 35) = Me.TextBox15
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 36) = Me.TextBox14
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 37) = Me.TextBox13
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 38) = Me.TextBox12
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 44) = Me.TextBox25
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 45) = Me.TextBox24
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 46) = Me.TextBox23
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 47) = Me.TextBox22
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 11) = Me.TextBox21
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 12) = Me.TextBox20
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 13) = Me.TextBox31
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 14) = Me.TextBox30
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 19) = Me.TextBox29
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 20) = Me.TextBox28
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 21) = Me.TextBox27
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 22) = Me.TextBox26
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 27) = Me.TextBox8
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 28) = Me.TextBox9
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 29) = Me.TextBox10
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 30) = Me.TextBox11
'und so weiter den Inhalt jeder Textbox
'in die entsprechende Spalte
End With
End Sub

Danke viel viel mal für eure kompetente Hilfe!
Grüsse & einen sonnigen Tag
Fabian

11
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Laufzeitfehler 9 beim UserForm eingabe
15.03.2012 09:38:49
Matthias
Hallo Fabian,
für was brauchst du das?
Dim shMain As Worksheet
Set shMain = ThisWorkbook.Sheets("Datenquelle_Titel")

arbeite doch direkt mit dem Blatt "Datenquelle_Titel"
with sheets ("Datenquelle_Titel")
AW: Laufzeitfehler 9 beim UserForm eingabe
15.03.2012 09:43:13
hary
Hallo Fabian
Hat sich evtl. ein Leerzeichen im Blattnamen eingeschlichen?

lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1

Brauchst Du nur einmal ganz oben.
gruss hary
klappt (bei mir) ohne Probleme
15.03.2012 09:53:11
Matthias
Hallo
Ich habe den Fehler nicht erzeugen können.
Mein minimierter Nachbau klappt ohne Probleme.
Userbild
Gruß Matthias
Anzeige
AW: @Matthias L.
15.03.2012 09:58:14
hary
Moin Matthias
Mach mal ein Leerzeichen vor den Namen im Reiter.
gruss hary
@hary
15.03.2012 10:01:12
Matthias
Hallo hary
Zitat!
Das File heisst tatsächlich "Datenquelle_Titel"
Gruß Matthias ;o)
AW: klappt (bei mir) ohne Probleme
15.03.2012 10:46:13
Fabian
Hallo Zusammen
Ich habe nun alles angepasst und es funktioniert nun auch einigermassen. Nur ein kleines Problem hab ich noch. Die Daten werden nicht wie gewünscht in die nächste entsprechende freie Zelle in der angegebenen Spalte geschrieben, sondern immer in Zeile 2 :(
Wie kann ich es bewerkstelligen, dass die Daten immer in die freie Zelle geschrieben werden?
Anbei nochmals der überarbeitete Code
Private Sub CommandButton1_Click()
Dim lz As Long
Dim shMain As Worksheet
Set shMain = ThisWorkbook.Sheets("Datenquelle")
With shMain
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 5) = Me.TextBox1
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 6) = Me.TextBox2
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 7) = Me.TextBox3
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 8) = Me.TextBox4
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 56) = Me.TextBox19
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 57) = Me.TextBox18
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 58) = Me.TextBox17
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 59) = Me.TextBox16
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 38) = Me.TextBox15
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 39) = Me.TextBox14
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 40) = Me.TextBox13
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 41) = Me.TextBox12
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 47) = Me.TextBox25
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 48) = Me.TextBox24
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 49) = Me.TextBox23
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 50) = Me.TextBox22
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 14) = Me.TextBox21
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 15) = Me.TextBox20
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 16) = Me.TextBox31
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 17) = Me.TextBox30
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 22) = Me.TextBox29
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 23) = Me.TextBox28
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 24) = Me.TextBox27
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 25) = Me.TextBox26
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 30) = Me.TextBox8
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 31) = Me.TextBox9
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 32) = Me.TextBox10
lz = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(lz, 33) = Me.TextBox11
'und so weiter den Inhalt jeder Textbox
'in die entsprechende Spalte
End With
End Sub

Anzeige
AW: klappt (bei mir) ohne Probleme
15.03.2012 11:34:02
hary
Hallo
so?

Private Sub CommandButton1_Click()
Dim lz As Long
Dim shMain As Worksheet
Set shMain = ThisWorkbook.Sheets("Datenquelle")
With shMain
lz = .Cells(.Rows.Count, 5).End(xlUp).Row + 1
.Cells(lz, 5) = Me.TextBox1
.Cells(lz, 6) = Me.TextBox2
.Cells(lz, 7) = Me.TextBox3
.Cells(lz, 8) = Me.TextBox4
.Cells(lz, 56) = Me.TextBox19
.Cells(lz, 57) = Me.TextBox18
.Cells(lz, 58) = Me.TextBox17
.Cells(lz, 59) = Me.TextBox16
.Cells(lz, 38) = Me.TextBox15
.Cells(lz, 39) = Me.TextBox14
.Cells(lz, 40) = Me.TextBox13
.Cells(lz, 41) = Me.TextBox12
.Cells(lz, 47) = Me.TextBox25
.Cells(lz, 48) = Me.TextBox24
.Cells(lz, 49) = Me.TextBox23
.Cells(lz, 50) = Me.TextBox22
.Cells(lz, 14) = Me.TextBox21
.Cells(lz, 15) = Me.TextBox20
.Cells(lz, 16) = Me.TextBox31
.Cells(lz, 17) = Me.TextBox30
.Cells(lz, 22) = Me.TextBox29
.Cells(lz, 23) = Me.TextBox28
.Cells(lz, 24) = Me.TextBox27
.Cells(lz, 25) = Me.TextBox26
.Cells(lz, 30) = Me.TextBox8
.Cells(lz, 31) = Me.TextBox9
.Cells(lz, 32) = Me.TextBox10
.Cells(lz, 33) = Me.TextBox11
'und so weiter den Inhalt jeder Textbox
'in die entsprechende Spalte
End With
End Sub

gruss hary
Anzeige
AW: klappt (bei mir) ohne Probleme
15.03.2012 11:40:13
Fabian
Hallo Hary
Danke für das schnelle Feedback.
Leider funktioniert auch das nicht. Wenn ich auf Submit Data in der CommandBox klicke dann passiert nichts.
Anbei habe ich mal das aktuelel File raufgeladen.
Vllt findet ihr den Fehler... Bin echt am verzweifeln :(
Grüsse
Fabian
https://www.herber.de/bbs/user/79375.xlsm
AW: kann auch nicht
15.03.2012 11:48:15
hary
Hallo fabian
schau mal in D64 da steht eine 1 drin, nimm die mal raus. Und ab geht die Post.
gruss hary
AW: kann auch nicht
15.03.2012 12:55:17
Fabian
woow! :)
Hat super geklappt - danke viel mal für die HIlfe Hary!
Schönen und hoffentlich auch sonnigen Nachmittag
Grüsse Fabian
Anzeige
AW: kann auch nicht
15.03.2012 12:55:22
Fabian
woow! :)
Hat super geklappt - danke viel mal für die HIlfe Hary!
Schönen und hoffentlich auch sonnigen Nachmittag
Grüsse Fabian

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige