AW: Frage zum Fehler
14.09.2013 22:28:47
Stefan
Hallo,
gebe das Worksheet immer an. Aber der Fehler liegt nicht hier, sondern in einem ganz anderen Code! Und zwar am EinfügenCode. Habe ihn geändert. Gefällt mir zwar nicht, dürfte aber gehen.
Private Sub CommandButton_Einfügen_Click()
Dim WS As Worksheet
Dim Loletzte As Long
If MultiPage1.Value = 0 Then
Set WS = Worksheets("MyPortal")
Else
Set WS = Worksheets("OneERP")
End If
With WS
Loletzte = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(Loletzte, 2) = TextBox_MyPortal_ID.Value
.Cells(Loletzte, 3) = TextBox_MyPortal_Bezeichnung.Value
.Cells(Loletzte, 4) = TextBox_S1_MyPortal.Value
.Cells(Loletzte, 5) = TextBox_S2_Myportal.Value
.Cells(Loletzte, 6) = TextBox_S3_Myportal.Value
.Cells(Loletzte, 7) = TextBox_S4_MyPortal.Value
.Cells(Loletzte, 8) = TextBox_S5_MyPortal.Value
.Cells(Loletzte, 9) = TextBox_S6_MyPortal.Value
'folgende Codezeile eingefügt. Fällt Dir was auf?
If MultiPage1.Value 0 Then
.Cells(Loletzte, 2) = TextBox_OneERP_ID.Value
.Cells(Loletzte, 3) = TextBox_OneERP_Bezeichnung.Value
.Cells(Loletzte, 4) = TextBox_S1_OneERP.Value
.Cells(Loletzte, 5) = TextBox_S2_OneERP.Value
.Cells(Loletzte, 6) = TextBox_S3_OneERP.Value
.Cells(Loletzte, 7) = TextBox_S4_OneERP.Value
.Cells(Loletzte, 8) = TextBox_S5_OneERP.Value
.Cells(Loletzte, 9) = TextBox_S6_OneERP.Value
End If
End With
Me.TextBox_MyPortal_ID = ""
Me.TextBox_MyPortal_Bezeichnung = ""
Me.TextBox_S1_MyPortal = ""
Me.TextBox_S2_Myportal = ""
Me.TextBox_S3_Myportal = ""
Me.TextBox_S4_MyPortal = ""
Me.TextBox_S5_MyPortal = ""
Me.TextBox_S6_MyPortal = ""
Me.TextBox_OneERP_ID = ""
Me.TextBox_OneERP_Bezeichnung = ""
Me.TextBox_S1_OneERP = ""
Me.TextBox_S2_OneERP = ""
Me.TextBox_S3_OneERP = ""
Me.TextBox_S4_OneERP = ""
Me.TextBox_S5_OneERP = ""
Me.TextBox_S6_OneERP = ""
End Sub