Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1212to1216
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

CodeFehler unterbinden ?

CodeFehler unterbinden ?
amintire
Hallo alle zusammen,
folgendes Problem bei dem Code,
wenn ich in TextBox31 etwas eingebe, ohne davor in ComboBox2 was ausgewählt zu haben, kommt ein Laufzeitfehler der mir den Bereich
' With Sheets(ComboBox2.Value) gelb markiert und ich auf Debuggen gehen kann.
Wie kann ich das am besten unterbinden?
So in der Art, das TextBox31 erst beschrieben werden kann, wenn davor auch etwas in ComboBox2 ausgewählt wurde, sodass der Laufzeitfehler gar nicht mehr erscheint.
Vielen Dank für eure Hilfe
Private Sub TextBox31_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim varTMP As Variant
Dim i As Long
With Sheets(ComboBox2.Value)
If TextBox31.Text > "" Then _
varTMP = Application.Match(CLng(CDbl(CDate(TextBox31.Text))), _
.Rows(4), 0)                                       'Zeile4
If TextBox31.Text > "" And Not IsError(varTMP) Then
TextBox4.Text = .Cells(5, varTMP).Value
TextBox5.Text = .Cells(6, varTMP).Value
TextBox6.Text = .Cells(7, varTMP).Value
TextBox7.Text = .Cells(8, varTMP).Value
TextBox8.Text = .Cells(9, varTMP).Value
TextBox9.Text = .Cells(10, varTMP).Value
TextBox10.Text = .Cells(11, varTMP).Value
TextBox11.Text = .Cells(12, varTMP).Value
TextBox12.Text = .Cells(13, varTMP).Value
TextBox13.Text = .Cells(14, varTMP).Value
TextBox14.Text = .Cells(15, varTMP).Value
TextBox15.Text = .Cells(16, varTMP).Value
TextBox16.Text = .Cells(17, varTMP).Value
TextBox17.Text = .Cells(18, varTMP).Value
TextBox18.Text = .Cells(19, varTMP).Value
TextBox19.Text = .Cells(20, varTMP).Value
TextBox20.Text = .Cells(21, varTMP).Value
TextBox21.Text = .Cells(22, varTMP).Value
TextBox22.Text = .Cells(23, varTMP).Value
TextBox23.Text = .Cells(24, varTMP).Value
TextBox24.Text = .Cells(25, varTMP).Value
TextBox25.Text = .Cells(26, varTMP).Value
TextBox26.Text = .Cells(27, varTMP).Value
TextBox27.Text = .Cells(28, varTMP).Value
TextBox28.Text = .Cells(29, varTMP).Value
TextBox29.Text = .Cells(30, varTMP).Value
TextBox30.Text = .Cells(31, varTMP).Value
Else
For i = 4 To 31
Me.Controls("TextBox" & i).Text = ""
Next
End If
End With
End Sub

Lieben Gruß
Amina

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: CodeFehler unterbinden ?
30.04.2011 17:59:29
Hajo_Zi
Hallo Amina,
davor If ComboBox2.Value"" then

AW: CodeFehler unterbinden ?
30.04.2011 18:05:53
amintire
Hallo Hajo,
then und dann ?
Und den Code
If ComboBox2.Value"" then
vor dem With Sheets(ComboBox2.Value)
oder ?
Gruß Amina
AW: ***
30.04.2011 18:14:44
amintire
Hallo Hajo,
irgendwie funktioniert es... Danke.
Gruß Amina
AW: CodeFehler unterbinden ?
30.04.2011 18:16:08
Hajo_Zi
Hallo Amina,
ja davor und hinter End With das End if.
Gruß Hajo
AW: Danke...
30.04.2011 18:30:34
amintire
Danke dir Hajo.
Gruß Amina
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige