Hallo liebe Experten,
habe ein rel. großes Problem und komme nicht weiter. Habe eine Excel Tabelle mit Formularen aufgebaut von den Zahlen in die entsprechenden Zellen eingefügt werden müssen. Mein Code:
Private Sub CommandButton3_Click()
Sheets(„Eingabemasken“).Activate
Cells(332, 3).NumberFormat = „#,###0.000“
Cells(333, 3).NumberFormat = „#,###0.000“
Cells(334, 3).NumberFormat = „#,###0.000“
Cells(335, 3).NumberFormat = „#,###0.000“
Cells(336, 3).NumberFormat = „#,###0.000“
Cells(337, 3).NumberFormat = „#,###0.000“
Cells(338, 3).NumberFormat = „#,###0.000“
Cells(339, 3).NumberFormat = „#,###0.000“
Cells(340, 3).NumberFormat = „#,###0.000“
Cells(341, 3).NumberFormat = „#,###0.000“
Cells(342, 3).NumberFormat = „#,###0.000“
Cells(343, 3).NumberFormat = „#,###0.000“
Cells(344, 3).NumberFormat = „#,###0.000“
Cells(345, 3).NumberFormat = „#,###0.000“
Cells(346, 3).NumberFormat = „#,###0.000“
Cells(347, 3).NumberFormat = „#,###0.000“
Cells(348, 3).NumberFormat = „#,###0.000“
Cells(349, 3).NumberFormat = „#,###0.000“
Cells(350, 3).NumberFormat = „#,###0.000“
Cells(352, 3).NumberFormat = „#,###0.000“
Cells(353, 3).NumberFormat = „#,###0.000“
Cells(355, 3).NumberFormat = „#,###0.000“
Cells(356, 3).NumberFormat = „#,###0.000“
Cells(357, 3).NumberFormat = „#,###0.000“
Cells(358, 3).NumberFormat = „#,###0.000“
Cells(360, 3).NumberFormat = „#,###0.000“
Cells(361, 3).NumberFormat = „#,###0.000“
Cells(364, 3).NumberFormat = „#,###0.000“
Cells(365, 3).NumberFormat = „#,###0.000“
Cells(367, 3).NumberFormat = „#,###0.000“
Cells(370, 3).NumberFormat = „#,###0.000“
Cells(371, 3).NumberFormat = „#,###0.000“
Cells(332, 3).Value = CDbl(TextBox1.Value)
Cells(333, 3).Value = CDbl(TextBox2.Value)
Cells(334, 3).Value = CDbl(TextBox3.Value)
Cells(335, 3).Value = CDbl(TextBox4.Value)
Cells(336, 3).Value = CDbl(TextBox5.Value)
Cells(337, 3).Value = CDbl(TextBox6.Value)
Cells(338, 3).Value = CDbl(TextBox7.Value)
Cells(339, 3).Value = CDbl(TextBox8.Value)
Cells(340, 3).Value = CDbl(TextBox9.Value)
Cells(341, 3).Value = CDbl(TextBox10.Value)
Cells(342, 3).Value = CDbl(TextBox11.Value)
Cells(343, 3).Value = CDbl(TextBox12.Value)
Cells(344, 3).Value = CDbl(TextBox13.Value)
Cells(345, 3).Value = CDbl(TextBox14.Value)
Cells(346, 3).Value = CDbl(TextBox15.Value)
Cells(347, 3).Value = CDbl(TextBox16.Value)
Cells(348, 3).Value = CDbl(TextBox17.Value)
Cells(349, 3).Value = CDbl(TextBox18.Value)
Cells(350, 3).Value = CDbl(TextBox19.Value)
Cells(352, 3).Value = CDbl(TextBox20.Value)
Cells(353, 3).Value = CDbl(TextBox21.Value)
Cells(355, 3).Value = CDbl(TextBox22.Value)
Cells(356, 3).Value = CDbl(TextBox23.Value)
Cells(357, 3).Value = CDbl(TextBox24.Value)
Cells(358, 3).Value = CDbl(TextBox25.Value)
Cells(360, 3).Value = CDbl(TextBox26.Value)
Cells(361, 3).Value = CDbl(TextBox27.Value)
Cells(364, 3).Value = CDbl(TextBox29.Value)
Cells(365, 3).Value = CDbl(TextBox30.Value)
Cells(367, 3).Value = CDbl(TextBox31.Value)
Cells(370, 3).Value = CDbl(TextBox33.Value)
Cells(371, 3).Value = CDbl(TextBox34.Value)
'Formular zurücksetzen
Dim tb As Object
With UserForm8
For Each tb In .Controls
If TypeName(tb) = „TextBox“ Then tb.Text = „“
Next tb
End With
End Sub
Beim Ausführen bekomme ich einen Laufzeitenfehler 13. Habe mit Leuten gesprochen, die haben mir gesagt, dass es an CDbl liegt und vorgeschlagen"On Error Resume Next " einzufügen. Doch das ist doch irgendwie nicht die Lösung. Ich habe CDbl mit Absicht hingetan, damit eine Zahl auch als eine Zahl und nicht als Text in Excel eingefügt wird und jetzt soll ich es umgehen?
Was sagt ihr? ES ist sehr wichtig.
Da ich nicht gerade der VBA-Profi bin, möchte ich euch bitten wenn es geht die Lösung an meinem Beispiel anzuwenden, das würde mir echt helfen!
Man hat mir vorgeschlagen folgendes zu benutzen, doch ich weiß leider nicht wie ich damit umgehen soll (HILFE):
Private Sub Text1_Change()
If Not IsNumeric(Text1.Text) Then
MsgBox „Das Feld darf nur Zahlen enthalten!“, vbCritical
End If
End Sub
Ich danke euch riesig
Gruß
Igor