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?
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