Home > database >  Excel VBA - make a range not selectable
Excel VBA - make a range not selectable

Time:10-14

Is there a way to make a range in an Excel file not selectable by the user?
Let's suppose I want cell F5 to be not selectable, so I'd like that if the user is entering data in cell F4 and then hits enter, the next cell to be selected be F6. The same if the user is using the arrow keys to move from an adjacent cell, i.e. from right G5 to left, the selected cell be E5 and not F5.

CodePudding user response:

'may you need like that code try to do in ***Worksheet_SelectionChange*** event :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   If ActiveCell.Address = "$F$5" Then ActiveCell.Offset(1, 0).Select
End Sub

that may helpful to you

  • Related