MoveAfterReturn does not function on protected sheet

TryingToLearn

Well-known Member
Joined
Sep 10, 2003
Messages
733
Excel 2016 on Win10
Activating the workbook turns moveafterreturn to false & immediate window confirms this is correct. for coding on the sheet to work properly the cell being changed needs to be the active cell.

If the sheet is not protected, all works fine. If the sheet is protected, all cells except the working row are locked HOWEVER,
the cursor moves to the next cell after hitting return. I have exported code to a new workbook with the same results. I've found several threads but no solution. What am I missing?

Code:
Private Sub Workbook_Activate()
    Dim Lrw
    'Record MoveAfterReturn settings
    Range("MvTF") = Application.MoveAfterReturn
    Range("MvDirec") = Application.MoveAfterReturnDirection
    Application.MoveAfterReturn = False     'Ensure no moves
    With Sheets("log")
        .Activate
        .Protect UserInterfaceOnly:=True
        .EnableSelection = xlUnlockedCells
        .Cells.Locked = True          'Lock all cells
        'Unlock next line to be used
        Lrw = .UsedRange.Rows.Count + .UsedRange.Row - 1
        Lrw = Lrw + 1
        Range(Cells(Lrw, Range("dt").Column).Address & ":" & Cells(Lrw, Range("entryno").Column).Address).Locked = False
        Cells(Lrw, Range("dt").Column).Select 'move to first entry item
    End With
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Why does a specific cell need to be active for code to work? If you need to read/write a cell, you can specify it - not use Selection or ActiveCell.

Anyway, I tested the code and MoveAfterReturn appears to be working correctly - that is, it is completely turned off
 
Upvote 0
Thank you for your response Tracy. As I enter data into the sheet, it is the active cell that is the focus of the code. Once I hit return, it is no longer the active cell if it advances to the next unprotected cell. Any other thoughts are appreciated on how to correct this.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top