List box

prkundan

New Member
Joined
Nov 13, 2018
Messages
17
Is it possible through VBA code to make a list box display its top value? How???
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Do you mean the Maximum value?

How did the listbox get it's values?

Good questions though. What are the answers? For instance, if the listbox is sourced by a query you can use the same query.
 
Upvote 0
Good questions though. What are the answers? For instance, if the listbox is sourced by a query you can use the same query.

I have the following code on the click event of the List Box:

Private Sub List_22215_Click()
On Error GoTo Err_code
Me.CR_NO = Left(Me.List_22215, 2) & Right("0000000" & CStr(CLng(Right(Me.List_22215, 5)) + 1), 5)
Me.List_22215.Requery
Me.DATE.SetFocus
Exit Sub
Err_code:
MsgBox Error$


End Sub

When I click on any value in the list box the cursor remains on that value. I want it to go to the first value (or the top value). For that I used Me.List_22215.Requery but it doesn't work.
 
Upvote 0
When I click on any value in the list box the cursor remains on that value. I want it to go to the first value (or the top value). For that I used Me.List_22215.Requery but it doesn't work.
When you say it doesn't work, what does it do? Does nothing at all happen? Does anything happen? Is there an error? Note that normally for changing a listbox selection you do something with the selected index value. Listboxes are a little weird because they have different kinds (multi select, single select, extended). You have to google a little and try different ways until you get the right syntax for accessing and working with listbox items.
 
Upvote 0
When you say it doesn't work, what does it do? Does nothing at all happen? Does anything happen? Is there an error? Note that normally for changing a listbox selection you do something with the selected index value. Listboxes are a little weird because they have different kinds (multi select, single select, extended). You have to google a little and try different ways until you get the right syntax for accessing and working with listbox items.



TRIED THE FOLLOWING COMMAND :
Me.List_22215 = Me.List_22215.ItemData(0)

AND IT WORKED.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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