ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Positioning the Insertion Point in a TextBox (https://www.excelbanter.com/excel-programming/289925-positioning-insertion-point-textbox.html)

DennisE

Positioning the Insertion Point in a TextBox
 
I've been wrestling with this one for days, and I just can't
seem to pull it off. What I'd like to do when a certain TextBox
on a UserForm takes the focus is to have the insertion point
automatically move one space to the left. So, for example,
if the TextBox contains ""ABC" upon taking the focus what
I want to see is "AB|C"; I've been trying to do this by using
Application.SendKeys "{LEFT}" in some manner but to no
avail. I can obviously do it manually by pressing the left arrow
key, but I want to do it in VBA so as to remind the user of how
the data entry appearing in that particular TextBox is to be
modified. Anyone have any ideas on how to do this?

-- Dennis Eisen

Tim Williams

Positioning the Insertion Point in a TextBox
 
Check out the "selstart" property of the textbox.
Setting selstart to len(textbox text)-1 and sellength to 0 should do
it.
Tim


"DennisE" wrote in message
...
I've been wrestling with this one for days, and I just can't
seem to pull it off. What I'd like to do when a certain TextBox
on a UserForm takes the focus is to have the insertion point
automatically move one space to the left. So, for example,
if the TextBox contains ""ABC" upon taking the focus what
I want to see is "AB|C"; I've been trying to do this by using
Application.SendKeys "{LEFT}" in some manner but to no
avail. I can obviously do it manually by pressing the left arrow
key, but I want to do it in VBA so as to remind the user of how
the data entry appearing in that particular TextBox is to be
modified. Anyone have any ideas on how to do this?

-- Dennis Eisen




DennisE

Positioning the Insertion Point in a TextBox
 
Tim,
Thanks. That indeed did the trick.

-- Dennis Eisen


All times are GMT +1. The time now is 09:23 AM.

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