VBA Userform Textbox - cursor to end of line after "TAB" selection (deselect content)

Llupo01

Active Member
Joined
Aug 17, 2015
Messages
296
Hello,

I would like to ask you for help... I cannot figure out, how to cancel selection of all text in textbox, after I activate this textbox by TAB key. This textbox has some pre-inserted value depending on previous combobox, anyway I would like to start typing after this pre-selected text when I activate this textbox - put cursor on 5th position and dont have text highlighted inside this textbox.

I tried Enter event, when tried
VBA Code:
txt1.selstart = 5
,
VBA Code:
txt1.setfocus
and combinations of selstart, selLenght etc...nothing wokred...it is always all highlighted, when I enter this textbox using tab order and key TAB.

Thank you in advance,

brgds,
Tomas
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi
Try following & see if helps you

Rich (BB code):
Private Sub TextBox1_Change()
    Dim ComboText As String
    ComboText = Me.ComboBox1.Value
    With Me.TextBox1
        .EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
        If Len(.Text) < Len(ComboText) Then .Value = ComboText
    End With
End Sub

Change control names shown in BOLD as required

Dave
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

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