ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Enter Key (https://www.excelbanter.com/excel-programming/311230-enter-key.html)

bw

Enter Key
 
We can use ToolsOptionsEditDirection to control the behaviour of the
Enter Key, but is there a way to have the Enter Key stay in the same cell?

I have removed the check mark from "Move Selection after Enter" to no
avail.

Thanks,
Bernie

Nick Hodge

Enter Key
 
Bernie

Unchecking should do it but...

You can certainly set this via code. This could either be in the workbooks
open even or you could use it as a toolbar button and toggle it on/off (as
per the code sample)

Sub moveAfterReturnNo()
If Application.MoveAfterReturn = False Then
Application.MoveAfterReturn = xlDown
Exit Sub
End If
Application.MoveAfterReturn = False
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"bw" wrote in message news:opsesoiborvzdmg1@bw...
We can use ToolsOptionsEditDirection to control the behaviour of the
Enter Key, but is there a way to have the Enter Key stay in the same cell?

I have removed the check mark from "Move Selection after Enter" to no
avail.

Thanks,
Bernie




bw

Enter Key
 
Thanks, Nick!

For some reason, "Unchecking" now works??? In any case, I appreciate the
code, and I'll save it for possible later use.

Bernie

On Thu, 23 Sep 2004 20:54:05 +0100, Nick Hodge
wrote:

Bernie

Unchecking should do it but...

You can certainly set this via code. This could either be in the
workbooks
open even or you could use it as a toolbar button and toggle it on/off
(as
per the code sample)

Sub moveAfterReturnNo()
If Application.MoveAfterReturn = False Then
Application.MoveAfterReturn = xlDown
Exit Sub
End If
Application.MoveAfterReturn = False
End Sub



bw

Enter Key
 
Nick,

I discovered why "Unchecking" didn't work. The Sheet is Protected, and
"Unchecking" doesn't work when the sheet is protected.

Also, "If ActiveSheet.Protect = True Then" is always False.

Do you have a solution to this problem?

Thanks,
Bernie

On Thu, 23 Sep 2004 20:54:05 +0100, Nick Hodge
wrote:

Bernie

Unchecking should do it but...

You can certainly set this via code. This could either be in the
workbooks
open even or you could use it as a toolbar button and toggle it on/off
(as
per the code sample)

Sub moveAfterReturnNo()
If Application.MoveAfterReturn = False Then
Application.MoveAfterReturn = xlDown
Exit Sub
End If
Application.MoveAfterReturn = False
End Sub



Tom Ogilvy

Enter Key
 
When you do Tools=Protect=worksheet, you have 3 choices. So there are
three properties to check (plus there is one more property that can be
protected, but only with code).

Worksheet object properties:
protectionMode
protectContents
protectscenarios
protectDrawingObjects

if any of them are true, then the sheet is protected.

--
Regards,
Tom Ogilvy


"bw" wrote in message news:opsessf8zmvzdmg1@bw...
Nick,

I discovered why "Unchecking" didn't work. The Sheet is Protected, and
"Unchecking" doesn't work when the sheet is protected.

Also, "If ActiveSheet.Protect = True Then" is always False.

Do you have a solution to this problem?

Thanks,
Bernie

On Thu, 23 Sep 2004 20:54:05 +0100, Nick Hodge
wrote:

Bernie

Unchecking should do it but...

You can certainly set this via code. This could either be in the
workbooks
open even or you could use it as a toolbar button and toggle it on/off
(as
per the code sample)

Sub moveAfterReturnNo()
If Application.MoveAfterReturn = False Then
Application.MoveAfterReturn = xlDown
Exit Sub
End If
Application.MoveAfterReturn = False
End Sub





bw

Enter Key
 
Thanks for the information, Tom, but when the sheet is PROTECTED, and
"Move Selection after Enter" is NOT checked, the Enter Key Moves to a
different cell (Right, Left, Down, or Up...whichever was last selected).

You don't need code to verify the statement above.

But still, I have the following code anyway (now), and it doesn't work
either.

Sub NoMoveAfterReturn()
If ActiveSheet.ProtectContents = True Then 'PROTECTED
ActiveSheet.Unprotect
Application.MoveAfterReturn = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Else 'UNPROTECTED
Application.MoveAfterReturn = False
End If
End Sub

I'm still looking for a suggestion that will work when the sheet is
protected.

Thanks,
Bernie


On Thu, 23 Sep 2004 21:00:50 -0400, Tom Ogilvy wrote:

When you do Tools=Protect=worksheet, you have 3 choices. So there are
three properties to check (plus there is one more property that can be
protected, but only with code).

Worksheet object properties:
protectionMode
protectContents
protectscenarios
protectDrawingObjects

if any of them are true, then the sheet is protected.



Tom Ogilvy

Enter Key
 
Thanks for the information, Tom, but when the sheet is PROTECTED, and
"Move Selection after Enter" is NOT checked, the Enter Key Moves to a
different cell (Right, Left, Down, or Up...whichever was last selected).


I couldn't reproduce that behavior. When I unchecked it and edited an
unlocked cell (protected sheet), when I hit enter, the highlight did not
move. Maybe it isn't clear what you are saying.

--
Regards,
Tom Ogilvy



"bw" wrote in message news:opses6c3b8vzdmg1@bw...
Thanks for the information, Tom, but when the sheet is PROTECTED, and
"Move Selection after Enter" is NOT checked, the Enter Key Moves to a
different cell (Right, Left, Down, or Up...whichever was last selected).

You don't need code to verify the statement above.

But still, I have the following code anyway (now), and it doesn't work
either.

Sub NoMoveAfterReturn()
If ActiveSheet.ProtectContents = True Then 'PROTECTED
ActiveSheet.Unprotect
Application.MoveAfterReturn = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Else 'UNPROTECTED
Application.MoveAfterReturn = False
End If
End Sub

I'm still looking for a suggestion that will work when the sheet is
protected.

Thanks,
Bernie


On Thu, 23 Sep 2004 21:00:50 -0400, Tom Ogilvy wrote:

When you do Tools=Protect=worksheet, you have 3 choices. So there are
three properties to check (plus there is one more property that can be
protected, but only with code).

Worksheet object properties:
protectionMode
protectContents
protectscenarios
protectDrawingObjects

if any of them are true, then the sheet is protected.





bw

Enter Key
 
I don't understand why you can make it work, and I can't?

I format cells A1:A3 as "Unlocked", then when I Protect the Sheet and
"Select Unlocked Cells" only.

I then uncheck "Move selection on Enter".

When I enter information into cell A1 and press Enter, the focus moves to
Cell A2.

Again, I don't understand why you can make it work, and I can't?

Bernie


On Thu, 23 Sep 2004 22:18:39 -0400, Tom Ogilvy wrote:

Thanks for the information, Tom, but when the sheet is PROTECTED, and
"Move Selection after Enter" is NOT checked, the Enter Key Moves to a
different cell (Right, Left, Down, or Up...whichever was last selected).


I couldn't reproduce that behavior. When I unchecked it and edited an
unlocked cell (protected sheet), when I hit enter, the highlight did not
move. Maybe it isn't clear what you are saying.



Tom Ogilvy

Enter Key
 
I could reproduce the behavior if I set the enableselection property of the
worksheet to xlUnlockedCells. If no restriction, it worked as expected.

--
Regards,
Tom Ogilvy

"bw" wrote in message news:opsetw76k7vzdmg1@bw...
I don't understand why you can make it work, and I can't?

I format cells A1:A3 as "Unlocked", then when I Protect the Sheet and
"Select Unlocked Cells" only.

I then uncheck "Move selection on Enter".

When I enter information into cell A1 and press Enter, the focus moves to
Cell A2.

Again, I don't understand why you can make it work, and I can't?

Bernie


On Thu, 23 Sep 2004 22:18:39 -0400, Tom Ogilvy wrote:

Thanks for the information, Tom, but when the sheet is PROTECTED, and
"Move Selection after Enter" is NOT checked, the Enter Key Moves to a
different cell (Right, Left, Down, or Up...whichever was last

selected).

I couldn't reproduce that behavior. When I unchecked it and edited an
unlocked cell (protected sheet), when I hit enter, the highlight did not
move. Maybe it isn't clear what you are saying.






All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com