3.4k Aufrufe
Gefragt in Tabellenkalkulation von
Hallo zusammen

Ich habe ein Datenerhebungsformular, wo ausser die Eingabefelder alle anderen Zellen geschützt sind. Nun möchte ich, dass z.B. von E2:M2 jeweils pro Zelle nur eine Zahl von 0 bis 9 eingegeben werden kann und dann der Cursor automatisch nach rechts springt OHNE Enter, Tab oder Pfeil Tasten zu betätigen. Also z.B. in Zelle E1 gebe drücke ich die Taste "6" und der Cursor hüpft sofort auf die Zelle F2 etc.

Kann mir da jemand weiterhelfen?

Schon mal besten Dank!
Gruss Hardy

24 Antworten

0 Punkte
Beantwortet von

Hallo Mingos, zunächst mal so:

Sub clean() 
  Range("C4", "G40").ClearContents
  Range("C2").Select
End Sub

Außerdem musst du den Code im Tabellenmodul noch um folgende Zeilen ergänzen (einfach unten nach der letzten Zeile anfügen)

Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("C2")) Is Nothing Then
    Range("B4").Select
  ElseIf Not Intersect(Target, Range("B4")) Is Nothing Then
    Range("C4").Select
  End If
End Sub

Soweit so gut. Allerdings wird bei mir aufgrund eines VBA-internen Bugs, für den ich nichts kann, durch Ausführen von End Sub alles zurückgesetzt. Bedeutet: In C4 musst du deine Eingabe wie gewohnt mit Enter abschließen. Ich habe in den letzten Tagen versucht diesen Bug zu umgehen, aber keine Chance. Vielleicht tritt das Problem ja bei dir nicht auf. Falls doch musst du wohl damit leben oder C4 manuell anwählen.

Gruß Mr. K.

0 Punkte
Beantwortet von

Hallo Mr. K.

vielen lieben Dank!!!

Funktioniert alles genau so wie ich es mir gewünscht habe!!!

Dir dann noch einen schönen 1. Advent angel

Gruß Mingos

0 Punkte
Beantwortet von
i am from Italy hello. Can you help me translate? /rardor
0 Punkte
Beantwortet von

Hi rardor,

sorry for my english. I'ts not the best :-)

The theme was to input 1 Digit inside a range and get directly result without activate the cell. Further it should change the selection to the next cell. Therefore we've used Application.OnKey to overwrite general activity of some keys with a macro (working for keys 0, 1, 2, Space and Enter) and blocked all other keys to avoid faulty insertion.

For the OnKey we've used keycodes of a german general keyboard. I'ts possible that you're keyboard has other keycodes. See here a very simple file I've created for the problem.

https://workupload.com/file/zr5Ew2Ac

Goto Range C4:G40 and try to input 1, 2 or 0. Or press Space or Enter and look what happens. Try also to input any character and find out: This is not possible because it's forbidden. This all is working only inside the defined range. If you have any questions don't hesitate to contact us here in this forum. But please create a new topic for your special problem.

Kind regards

Mr. K.

...