ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Keypress and "Enter" key (https://www.excelbanter.com/excel-programming/314877-keypress-enter-key.html)

Thomas[_13_]

Keypress and "Enter" key
 
This is what I am trying to do:

For a given cell in column B I want to make a manual entry, e.g., in B10.
When I press return I want a VBA routine to run that will enter information
into the adjacent cell in column A, A10 in this case. KeyPress function
does not respond to the "event" of return being pressed. Is there a way to
detect the return or "Enter" key being pressed?

Thanks.

Thomas



Harald Staff

Keypress and "Enter" key
 
Hi Thomas

No. But Enter completes a cell entry, and there's a useful event detecting
just that. Rightclick the sheet tab, choose View Code, paste this in:

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox "You wrote " & Target(1).Formula & _
" in " & Target(1).Address
End Sub

See Chip's page
http://www.cpearson.com/excel/events.htm
for theory on this.

HTH. best wishes Harald

"Thomas" skrev i melding
...
This is what I am trying to do:

For a given cell in column B I want to make a manual entry, e.g., in B10.
When I press return I want a VBA routine to run that will enter

information
into the adjacent cell in column A, A10 in this case. KeyPress function
does not respond to the "event" of return being pressed. Is there a way

to
detect the return or "Enter" key being pressed?

Thanks.

Thomas






All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com