VBA: keypress

  • Not sure what you are looking for. You can always get the value of the active cell by Activecell.value whether you arrived there with a tab or other means shouldn't matter. Do you mean you want the value only if the cell was entered with a tab key and you want something to tell you when the tab key was pressed?

  • The keypress command does not work on TAB. You could try this but its probably not quite what you are looking for.
    Place this code in the sheet1 module:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.OnKey "{TAB}", "SeeVal"
    End Sub

    ..and this code in module1:

    Sub SeeVal()
    Cells(ActiveCell.Row, ActiveCell.Column + 1).Select
    MsgBox ActiveCell.Value
    End Sub

    This wiil make the cursor TAB right and display a msgbox with the cell value.
    The downside is that using OnKey disables & over-rides the regular TAB behaviour.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!