PDA

View Full Version : Disable Arrow Keys



felipesaloma
04-20-2012, 03:28 AM
Hi, i would like to know how i can disable arrows keys if i select determined range of cells (for example A1:A20), i am asking that because i run macro when somebody change value of this cells automatically and if person press left/right arrow key, macro not work fine, so i would like to arrow lock on this range of cells, its possible ? Thanks

felipesaloma
04-20-2012, 01:20 PM
Somebody have solution or part of solution ? Please help me. Thanks for all

Kenneth Hobs
04-20-2012, 07:27 PM
Sounds like you need to modify your code instead.

To run a macro use OnKey(). Type OnKey in the VBE and press F1 for help to see how it is used.

felipesaloma
04-21-2012, 07:39 AM
Sounds like you need to modify your code instead.

To run a macro use OnKey(). Type OnKey in the VBE and press F1 for help to see how it is used.

Hi i want use only macro work if i press ENTER. My Macro code is:

Sub Macro8()
Application.ScreenUpdating = False

ActiveCell.Offset(-1, 0).Rows("1:1").EntireRow.Select
Selection.Copy
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(0, 2).Range("A1:G1").Select
Application.CutCopyMode = False
Selection.ClearContents

ActiveCell.Offset(0, 0).Range("A1").Select
End Sub

My Sheet code that make macro run automatically on change is:


Private Sub Worksheet_Activate()
Application.DisplayFullScreen = True
Application.DisplayStatusBar = False
Application.DisplayFormulaBar = False
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayVerticalScrollBar = False
ActiveWindow.DisplayWorkbookTabs = False
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
If Not Intersect(Target, Range("I5:I50000")) Is Nothing Then
Call Módulo1.Macro8
End If

Application.EnableEvents = False
If Not Intersect(Target, Range("F7800:F50000")) Is Nothing Then
Call Módulo3.Macro3
End If

Application.EnableEvents = True
End Sub
Private Sub cmd_edicao_Click()

Application.DisplayFullScreen = False
Application.DisplayStatusBar = True
Application.DisplayFormulaBar = True
ActiveWindow.DisplayHeadings = True
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayVerticalScrollBar = True
ActiveWindow.DisplayWorkbookTabs = True
End Sub
Private Sub Cmd_voltar_Click()
Sheets("Resumo").Select
End Sub
Private Sub cmd_save_Click()
ActiveWorkbook.Save
End Sub
Private Sub cmd_exit_Click()
Application.Quit
End Sub

Cells that run macro automatically is I5:I5000, i dont know how to patch it to only work if press ENTER, Can you help me add this OnKey command to my code ? Thanks

felipesaloma
04-23-2012, 11:28 PM
Please help solve it guys, should not be too complex...