Code schreibt unverständlicherweise eine 0
22.03.2014 10:40:32
Marc
über folgende Code schreibe ich Werte mit einem cmb in eine bestimmte Zelle. Der Code an sich ist noch großer aber der hund ist hier irgendwo begraben.
Sobald ich den cmb betätige schreibt er mir in die B-Spalte eine 0.
Was sehr ungünstig ist da ich da eine Formel drin haben will :/
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox1).Column) = Format(CDbl(TextBox3))
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox2).Column) = Format(CDbl(TextBox4))
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox3).Column) = Format(CDbl(TextBox5))
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox4).Column) = Format(CDbl(TextBox6))
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox5).Column) = Format(CDbl(TextBox7))
der gesamte Code sieht wie folgt aus.
Private Sub CommandButton2_Click()
Cells(Cells(Rows.Count, "D").End(xlUp).Row + 1, "D").Value = CDate(TextBox1.Text) 'erste freie _
Zelle in SpalteD fuer Datum
Cells(Cells(Rows.Count, "D").End(xlUp).Row, "E").Value = TextBox2.Text 'erste freie Zelle fuer _
Beschreibung
' Einzelwerte nach Spalte(combobox) in Zelle eintragen
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox1).Column) = Format(CDbl( _
TextBox3))
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox2).Column) = Format(CDbl( _
TextBox4))
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox3).Column) = Format(CDbl( _
TextBox5))
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox4).Column) = Format(CDbl( _
TextBox6))
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox5).Column) = Format(CDbl( _
TextBox7))
If CheckBox1 = True Then
Cells(Cells(Rows.Count, "D").End(xlUp).Row, "F").Value = "X"
Else
Cells(Cells(Rows.Count, "D").End(xlUp).Row, "F").Value = ""
End If
Label7 = Cells(Cells(Rows.Count, "D").End(xlUp).Row + 1, "A").Value ' Lfd.-Nr. aktualisieren
'Comboboxen und Textbox leeren
TextBox2 = ""
CheckBox1 = False
ComboBox1 = ""
ComboBox2 = ""
ComboBox3 = ""
ComboBox4 = ""
ComboBox5 = ""
TextBox3 = Format(0, "#0.00")
TextBox4 = Format(0, "#0.00")
TextBox5 = Format(0, "#0.00")
TextBox6 = Format(0, "#0.00")
TextBox7 = Format(0, "#0.00")
End Sub
Gruß Marc