Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving to a cell

Status
Not open for further replies.

luceze

Programmer
Apr 26, 2001
842
US
In MS Excel, has anyone ever written anything that when in a cell and pressing enter instead of moving to the next cell the focus stays in the original cell. I think that makes sense.
 
you can go to Tools>Options>Edit and uncheck the box that says Move selection after Enter, or you can choose which way you want to go when you press enter.
 
That works but it turns it off for the whole application. I would like to apply that function to just one cell or sheet or workbook. Whichever level is possible.
 
None of the above.

This will set "Move selection after Enter" for the current Excel session.

Sorry.
 
If you want it to only apply to one cell use this. It is a bit slow so I wouldn't use it. It is up to you.

Place this in VBA in the Sheet with the cell you want it to apply to.

The Cell this applies to is A2 as you can see. Just change this address for your cell.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$A$2" Then
Application.MoveAfterReturn = False
Else
Application.MoveAfterReturn = True
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top