Moin!
Cells() ohne korrekte Referenzierung bezieht sich IMMER auf das ActiveSheet!
Benutze eine With-Klammer und beachte die Punkte vor Cells():
Private Sub CommandButton_Einfügen_Click()
Dim last As Long
With Sheets("Datenbank")
last = .Cells(Rows.Count, 2).End(xlUp).Row + 1
.Cells(last, 1).Value = "Standardanlage"
.Cells(last, 2).Value = ComboBox_AnlagenTyp
.Cells(last, 3).Value = TextBox_Kunde
.Cells(last, 4).Value = TextBox_Projektleiter
.Cells(last, 5).Value = TextBox_Auftragsnummer
.Cells(last, 7).Value = TextBox_CENummer
.Cells(last, 10).Value = TextBox_OrdnerNummer
.Cells(last, 8).Value = ComboBox_Konstruktionsjahr
.Cells(last, 6).Value = TextBox_Lieferdatum
.Cells(last, 11).Value = TextBox_SiebNummer
.Cells(last, 15).Value = TextBox_Erreger1Nummer
.Cells(last, 16).Value = TextBox_Erreger2Nummer
.Cells(last, 17).Value = TextBox_Pumpe1Nummer
.Cells(last, 18).Value = TextBox_Pumpe1MotorNummer
.Cells(last, 20).Value = TextBox_Pumpe2Nummer
.Cells(last, 21).Value = TextBox_Pumpe2MotorNummer
End With
MsgBox ("Die Daten wurden erfolgreich in die Datenbank eingegeben!")
Unload UserForm2
ActiveWorkbook.Save
End Sub
Gruß Ralf
|