Ignore Left arrow key press

MikeHazell

New Member
Joined
Jan 21, 2019
Messages
3
Hi

I'm new to using this forum and only dabble in VBA so my apologies if I make mistakes in my attempt to get the information I require.

I want the Left Arrow key press to be ignored if the active cell is in column one. Without it being ignored the active cell now moves up one row and to the furthest available cell to the right.

I would like the code that would do the perform as follows:


"If column is column one and the left arrow key has been pressed then column one stays as column one and row number remains the same."

I hope there is someone who can see what I am trying to do and can help me.

Thasnks
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,277
One way to deal with your problem

Code goes in SHEET module
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Application
       If Target.Column = 1 Then .OnKey "{LEFT}", "" Else .OnKey "{LEFT}"
    End With
End Sub
 

MikeHazell

New Member
Joined
Jan 21, 2019
Messages
3
This was not the way I was looking for a solution but this is very acceptable.

Thank you Yongle
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,277
Detecting a Left Arrow press occurring in a worksheet is more complicated than temporarily disabling it
(but it is easy to detect inside userform objects)
 
Last edited:

Forum statistics

Threads
1,078,393
Messages
5,339,923
Members
399,340
Latest member
JasonT903

Some videos you may like

This Week's Hot Topics

Top