How do I limit a cell to one digit and have it automatically tab?

H

HJB1954

I am trying to enter one digit numbers to cells. I would like for Excel to
automatically tab me to the next cell without having to hit the enter or tab
key. Is it possible??

Thanks,

Harold Buchanan
 
J

Jim Thomlinson

Not possible. There is no buillt in feature to allow this and macros are
suspended while you are entering data in a cell.
 
D

Dave Peterson

Without knowing what "the next cell" means...

Saved from a previous post:

I would turn
tools|options|edit tab|move selection after enter
to down or right or ...

Then turn number lock on and use the numeric keypad to type your digit

Hitting the enter key on the numeric keypad doesn't seem too bad to me.

Another alternative is to create a tiny userform that just looks for a digit:

Put a single textbox on it (use the X button to close the userform).

Put this code in a General module:

Option Explicit
Sub testme01()
Cells(ActiveCell.Row, 1).Activate
UserForm1.Show
End Sub

Add this code to the userform module:

Option Explicit
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

Select Case KeyAscii
Case 48-57 'Numbers 0-9
With ActiveCell
.Value = Chr(KeyAscii)
'A:E, then down a row
if activecell.column = 5 then
activecell.entirerow.cells(1).offset(1,0).activate
else
.Offset(0, 1).Activate
end if
End With
End Select
KeyAscii = 0
TextBox1.Value = ""

End Sub

This code goes from A:E then next row, column A.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Debra Dalgleish has some getstarted instructions for userforms at:
http://contextures.com/xlUserForm01.html
 
H

HJB1954

Not the answer I wanted to hear, but at least I know. Thanks for responding.

Harold Buchanan
 
H

HJB1954

Wow! I am afraid I am in over my head. I have written a program that
calculates the bets we have made while playing golf. As each team comes in,
they give me the scores for each hole. I then enter them and the simple
programming I have done calculates the bets.

As they call out, 5, 4, 3, 5, 4, 2, 4,4,4, I would like to be able to go to
the cell for hole number one and enter 5.

Will the formula you wrote let me enter 5 and then go to the cell which is
adjacent to it and enter 4 without having to tab to that cell.

If so, I will get more familiar with userforms and use your suggestion.

Thanks for responding.

Harold Buchanan
 
D

Dave Peterson

It's not a formula--it's a macro.

It will allow you to enter a single digit and go to the adjacent cell. You may
have to modify the code so that it goes to the next row after the 9th entry,
though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top