Finding the cursor position in a text box on a userform

Bengt

Active Member
Joined
Mar 4, 2008
Messages
267
Hello,
How do I do to find where the cursor is positioned in a text box on a user form? I know that I can use EnterFieldBehavior= 1 and textbox1.selstart to find out where the selection is, or the cursor position when I type a text. However, if I have typed some text and then do a few left arrows, so that the cursor is no longer at the end of the text, the value that you get from textbox1.selstart does not give you the updated position. As soon as I make some sort of selection though, or insert more text in the middle of the current text, selstart is updated, but I don't want to enter anything. I simply would like to know: Where, in what position, is my cursor right now?

Can this be done, and if so, has anyone got a code snippet to share?

Thanks

Bengt
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,203,241
Messages
6,054,321
Members
444,717
Latest member
melindanegron

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top