ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to change (override) enter key behaviour in a cell (https://www.excelbanter.com/excel-programming/326625-how-change-override-enter-key-behaviour-cell.html)

helpwithXL

how to change (override) enter key behaviour in a cell
 
thanx to all who replied to my last post regarding enter key behaviour.
but problem is still not solved. i think i should have been more clear.
the moveAfterReturn method is only boolean type and it tells if the
enter key will be effective or not, that is, if moveAfterReturn = true
(by default),then pressing enter will take the user to next cell and if
moveAfterReturn = false then pressing enter will not have any effect at
all. moveAfterReturnDirection tells only direction in which cell
selection will move.
my problem is that i want to go to the next line in the SAME cell when
i press enter and not to the next cell. i can go to next line in same
cell by alt+enter (now also) but i have a specific requirement in which
i have to over ride enter key so that when user presses enter key , the
cursor remains in the same cell but on the next line.

TIA
regards


Jim Thomlinson[_3_]

how to change (override) enter key behaviour in a cell
 
Look up the OnKey method in VBA help. I think that is what you want...

HTH

"helpwithXL" wrote:

thanx to all who replied to my last post regarding enter key behaviour.
but problem is still not solved. i think i should have been more clear.
the moveAfterReturn method is only boolean type and it tells if the
enter key will be effective or not, that is, if moveAfterReturn = true
(by default),then pressing enter will take the user to next cell and if
moveAfterReturn = false then pressing enter will not have any effect at
all. moveAfterReturnDirection tells only direction in which cell
selection will move.
my problem is that i want to go to the next line in the SAME cell when
i press enter and not to the next cell. i can go to next line in same
cell by alt+enter (now also) but i have a specific requirement in which
i have to over ride enter key so that when user presses enter key , the
cursor remains in the same cell but on the next line.

TIA
regards



helpwithXL

how to change (override) enter key behaviour in a cell
 
thanx Jim,
this is exactly what i wanted but can u also tell how to make the
cursor go down when i'm editing the cell.
so with onKey i can assign a new sub whenever enter key is pressed but
how do i write this syntactically in the sub i assigned, that i want
the cursor to go down and have a line feed. i tried vbcrlf but it does
not work.

TIA
regards


Jim Thomlinson[_3_]

how to change (override) enter key behaviour in a cell
 
As a guess without trying it you want to use SendKey to send the Alt Enter
keystroke

HTH

"helpwithXL" wrote:

thanx Jim,
this is exactly what i wanted but can u also tell how to make the
cursor go down when i'm editing the cell.
so with onKey i can assign a new sub whenever enter key is pressed but
how do i write this syntactically in the sub i assigned, that i want
the cursor to go down and have a line feed. i tried vbcrlf but it does
not work.

TIA
regards




All times are GMT +1. The time now is 12:32 AM.

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