preselect listbox item

greg kramer

New Member
Joined
Dec 13, 2009
Messages
24
I know that you can select an item or preselect an item with the following syntax:

listbox.selected(1) = true

but how would one convert the 1 to text from another source so that it would work the same way

that is,

listbox.selected("word")=true

probably not formulating the question very well but any thoughts would be appreciated.
 
LOL - No biggie - I prefer Timmy's coffee - I am in Canada - if you get a type mismatch make sure that it is a string comparison (how did you dimension your value" - maybe poste a bit of the code - just to illustrate the problem.
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Greg

Is the value you want to preselect definitely going to be in the list?
Code:
Dim dftIndex
 
Dim DftIndex
Dim DftValue As String
 
    DftValue = Range("DefaultValue").Value

    DftIndex = Application.Match(DftValue, Range(ListBox1.ListFillRange), 0)
 
    If Not IsError(DftIndex) Then
        ListBox1.Selected(DftIndex - 1) = True
    End If
 
Upvote 0
Thank you all for your assistance!

Was able to get some code working.

Hope I'm able to start being contributer rather than a taker soon.

Regards,

Greg
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,718
Members
452,939
Latest member
WCrawford

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