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
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,258
Office Version
365
Platform
Windows
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
5,258
Office Version
365
Platform
Windows
What were you thinking of?
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,258
Office Version
365
Platform
Windows
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,089,449
Messages
5,408,291
Members
403,195
Latest member
biafrapl

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top