hab mir folgenden Code besorgt:
Sub nurzahlen()
Dim varEingabe As Variant
Dim lngEingabe
On Error GoTo nochmal
nochmal:
lngEingabe = CLng(Application.InputBox("Eingabe"))
On Error GoTo 0 ' on Error zurücksetzen
End Sub
der mir nur Zahlen als Eingabe zulässt, funktioniert auch soweit. Das Problem ist nur, dass, wenn ich eine MsgBox dazwischen schalte, beim Ausführen des Codes zuerst die MsgBox kommt und dann erst das Eingabefeld.
meinte so:
Sub nurzahlen()
Dim varEingabe As Variant
Dim lngEingabe
On Error GoTo nochmal
nochmal:
MsgBox("Falsche Eingabe:")
lngEingabe = CLng(Application.InputBox("Eingabe"))
On Error GoTo 0 ' on Error zurücksetzen
End Sub
Das will ich aber nicht. Es soll zuerst die Abfrage kommen und falls eine falsche Eingabe gemacht wurde, dann die MsgBox.
Am liebsten wäre mir , wenn man nur ganze Zahlen zwischen 1 und 9999 eingeben könnte (momentan alles mit runden, also 1,67 wird 2).
Bin für jeden Tipp dankbar.
Gruß
Christian