CodeFehler unterbinden ?
amintire
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