Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1352to1356
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Code schreibt unverständlicherweise eine 0

Code schreibt unverständlicherweise eine 0
22.03.2014 10:40:32
Marc
Hallo,
ü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

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Code schreibt unverständlicherweise eine 0
22.03.2014 10:54:26
hary
Moin Marc
Vlt. hilf es wenn du vorher pruefst.
if Rows(2).Find(ComboBox1).Column  2
dein Code
end if

Kann von allen Cbos die SpalteB kommen?
gruss hary

AW: Code schreibt unverständlicherweise eine 0
22.03.2014 10:56:26
Marc
habs gelöst aber danke für deine Hilfe.
Problem war wenn eine Combobox leer war hat er die 0 aus der Textbox geschrieben,
habs über if gelöst
' Einzelwerte nach Spalte(combobox) in Zelle eintragen
If ComboBox1 = "" Then
Else
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox1).Column) = Format(CDbl(TextBox3))
End If
If ComboBox2 = "" Then
Else
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox2).Column) = Format(CDbl(TextBox4))
End If
If ComboBox3 = "" Then
Else
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox3).Column) = Format(CDbl(TextBox5))
End If
If ComboBox4 = "" Then
Else
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox4).Column) = Format(CDbl(TextBox6))
End If
If ComboBox5 = "" Then
Else
Cells(Cells(Rows.Count, 4).End(xlUp).Row, Rows(2).Find(ComboBox5).Column) = Format(CDbl(TextBox7))
End If
Danke noch mal!!
Anzeige

281 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige