Need help identifying combobox property or method

AnnaHansen

Board Regular
Joined
Oct 27, 2014
Messages
58
I have a combobox on a userform that pre-selects an item if it thinks it knows what the user is going to select, based on a very simple prediction that I put together.

If it guesses wrong, then of course the user needs to find the correct item they want. Most users are using a keyboard to make selections and would start typing the value they want to select, rather then using the drop down or using the up/down arrows to scroll through the list.

Problem is, once the combobox makes a guess, the "cursor" (the cursor is not actually visible) is at the end of the predicted item, so the user has to highlight it all and delete it, or hold down backspace before they can start typing to find their value. (I have MatchEntry set to fmMatchEntryComplete)

I also have textboxes that do a similar prediction thing, and in that case, using the .setfocus command on the textbox after the prediction sets the value highlights the predicted text and so the user can just start typing to overwrite it if it is wrong.

The .setfocus command on the combobox makes the combobox the active element on the form but doesn't highlight the text.

Does anyone know how to have it select the text (or if it even can be done)?

Thanks,
 

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
Hi,
look at using the SelStart, SelLenght & SelText properties of the control to see if these properties will do what you want.

As an example:

Code:
    With Me.ComboBox1
        .SelStart = 0
        .SelLength = .TextLength
    End With

should select the text in the control if it has focus.

Dave
 
Upvote 0
Hi,
look at using the SelStart, SelLenght & SelText properties of the control to see if these properties will do what you want.

As an example:

Code:
    With Me.ComboBox1
        .SelStart = 0
        .SelLength = .TextLength
    End With

should select the text in the control if it has focus.

Dave



Worked like a charm! Thank you for your help!!:biggrin:
 
Upvote 0

Forum statistics

Threads
1,215,561
Messages
6,125,533
Members
449,236
Latest member
Afua

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