0

Is it possible, in Excel or Excel-VBA, set a cell so that when the user digit two characters it automatically change to the next cell?

In my particular case, I want to create a excel form where the user do need to insert dates, so that each column works as day, month or year. For exemple, if the date to be inserted is 09/july/1977, the user insert only "09" in the first cell (the day column), then excel automatically changes to next cell (the month column), where the user digit "07", and finally excel changes automatically to the last cell (the year column), where excel shows a message automatically after the user digits "77".

Community
  • 1
  • 1
sergio trajano
  • 189
  • 1
  • 1
  • 14
  • 2
    In short; No there is not. – Scott Craner Mar 08 '18 at 16:16
  • 1
    To better clarify, there is no VBA event that listens to the keystrokes in a cell. You may be able to accomplish something somewhat similar with data-validation but this would only accept/reject input, it would not automatically change the active cell. – Brandon Barney Mar 08 '18 at 16:18
  • Thank you @ScottCraner and Brandon! – sergio trajano Mar 08 '18 at 16:18
  • 1
    You can find instructions on how to capture key-presses during cell entry [here](https://stackoverflow.com/a/11154285/9290986). Not sure if it would let you move to the next cell and keep what you have typed properly though – Chronocidal Mar 08 '18 at 16:23
  • Thank you Chronocidal! I will do some tests and then post the results here. – sergio trajano Mar 08 '18 at 16:29
  • Let's step back - *why* do you want this behavior? Is it because you want to do something with the month, day, year -- so you're having the user put each part in its own cell? An alternative is to let the user enter the date in a single cell, and just use a formula to pull that formula apart in different cells. That way the user can enter, in a single entry, `09 July 1977`, and you can split that up later. Would that work instead? – BruceWayne Mar 08 '18 at 16:43
  • BruceWayne, in fact, this is going to be my first step towards a voice-to-text excel form, where the user is going to pronounce numbers, from 1 to 99, and excel, in addiction to a second app, will insert each number as a day, month or year, depending on which is the active cell. I just do not exposed all those details before for the sake of simplicity, but now I can say my exactly desire: the user say "one", the app send "01" to the keyboard, and the active cell will change to the next, and so on. The set of 1 to 99 is small, so I think the artificial intelligente of the app could handle it. – sergio trajano Mar 08 '18 at 17:41

0 Answers0