Warum verhindert diese Zeile im Code die Übertragung vom Textfeld zur Tabelle
Columns("C:C").EntireColumn.AutoFit
Lösche ich diese Zeile funzt das
Danke für eure Unterstützung
Private Sub TextBox_MyPortal_ID_Change()
If Not IsNumeric(TextBox_MyPortal_ID.Value) Then
CommandButton_Einfügen.Enabled = False
ElseIf IsNumeric(TextBox_MyPortal_ID.Value) Then
CommandButton_Einfügen.Enabled = True
End If
If Me.TextBox_MyPortal_ID.Value = "" Then
CommandButton_Einfügen.Enabled = False
End If
Columns("B:B").EntireColumn.AutoFit
End Sub
Danke
Private Sub TextBox_OneERP_ID_Change()
If Not IsNumeric(TextBox_OneERP_ID.Value) Then
CommandButton_Einfügen.Enabled = False
ElseIf IsNumeric(TextBox_OneERP_ID.Value) Then
CommandButton_Einfügen.Enabled = True
End If
If Me.TextBox_OneERP_ID.Value = "" Then
CommandButton_Einfügen.Enabled = False
End If
Columns("B:B").EntireColumn.AutoFit
End Sub
In diesem Code funktioniert es. Der einzige Unterschied ist die Bezeichnung der Textbox
Worksheets("......").Columns("B:B").EntireColumn.AutoFit
Die Punkte entsprechen dem richtigen Tabellenblatt.
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
Worksheets("......").Columns("B:B").EntireColumn.AutoFit
sollte man die Codezeile soWorksheets("......").Columns(2).EntireColumn.AutoFit
schreiben weil Excel im ersten Fall den Wert erst in eine Zahl konvertieren muss. Hast Du übrigens meine Antwort gesehen? Die sollte doch den 'Fehler' beseitigen.