ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determine if Carriage Return or Tab key is used (https://www.excelbanter.com/excel-programming/404890-determine-if-carriage-return-tab-key-used.html)

MarkB

Determine if Carriage Return or Tab key is used
 
I need to show a message box if the user enters an "N" in any particular
cell. I currently have code in the SelectionChange procedure, which checks to
see if the cell direcly above or to the left of the active cell has the "N".
This causes a problem because if a user is entering information on the next
line, when the active cell is direcly below a cell with only an "N", it shows
the message box. So, I am wanting to write a procedure that is triggered when
the user hits either Enter or Tab to check if the last active cell has only
an "N".

Please help if you can.

Thanks,
--
Markb

SeanC UK[_2_]

Determine if Carriage Return or Tab key is used
 
Hi Mark,

Using the Worksheet_SelectionChange event passes the newly selected range as
Target. If you want to check the last cell that had data entered then try
using the Worksheet_Change event to trigger your code. This passes the range
of the changed cell. Also this only happens when cell contents are changed,
whereas the SelectionChange event occurs after every new selection, and
therefore will be triggering your code far more often.

If this isn't quite what you were looking for then let me know and I'll try
to help further.

Cheers,

Sean.
--
(please remember to click yes if replies you receive are helpful to you)


"markb" wrote:

I need to show a message box if the user enters an "N" in any particular
cell. I currently have code in the SelectionChange procedure, which checks to
see if the cell direcly above or to the left of the active cell has the "N".
This causes a problem because if a user is entering information on the next
line, when the active cell is direcly below a cell with only an "N", it shows
the message box. So, I am wanting to write a procedure that is triggered when
the user hits either Enter or Tab to check if the last active cell has only
an "N".

Please help if you can.

Thanks,
--
Markb



All times are GMT +1. The time now is 12:13 PM.

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