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
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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