Keypress and "Enter" key

T

Thomas

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
 
H

Harald Staff

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top