Select first item in listbox

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,213
Office Version
  1. 2007
Platform
  1. Windows
Hi,
Currently when i open the ListBox1 its first entry shown is actualy the second entry.
Make sense ?
I need to pull the sliderdown to see the correct first entry.

Here is the code.
Ive tried various options but each time im still seeing the second.

VBA Code:
Private Sub ListBox1_Click()
    If ListBox1.ListCount > 0 Then
    ListBox1.ListIndex = 0
    End If
      Dim answer As Integer
 
  Range("A" & ListBox1.List(ListBox1.ListIndex, 1)).Select
  answer = MsgBox("OPEN DATABASE ?", vbYesNo + vbCritical, "OPEN DATABASE MESSAGE")
   If answer = vbYes Then
   Unload DatabaseNameSearch
   Database.Show

Else
    Unload DatabaseNameSearch
End If
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
It’s a list box where only 1 item will be selected.
 
Upvote 0
I’m sure I tried that but still the second value was shown.
 
Upvote 0
what are you attempting to do with that code? Seems wrong to me... Like it should be the AfterUpdate and not Click

also it sounds like a combobox and not a listbox?
 
Upvote 0
It’s a code I’m currently working with.
What you see works fine at present apart from when the values are shown in the listbox the first value is hidden.
I then need to grab the slider to pull down then I see the first value.
If I didn’t know that I would assume that the first entry you see is the first value. But I know the name of the first true value. Any other user would then see the wrong information.
 
Upvote 0
Evening,
Please see screenshot.

In The Type Name Box i enter the letter A
All results with the letter A are then shown on the right in the listbox.

As you can see the entry shown at what you think would be the first is A SQUARED 001

Now look on the worksheet behind & you will see the first is actually A BAKALI 001

Grabbing the slider on the right side & pushing it up then brings A BAKALI into view.

So the object of this task is to have the first entry NOT the second entry shown like so.
@jasonb75
 

Attachments

  • 6129.jpg
    6129.jpg
    198.4 KB · Views: 17
Upvote 0
It seems that you've a coded connection with a textbox and your listbox. Check the regarding code and consider to insert on the change_event of that control a Me.Repaint to force a repaint of the Userform. That's all I can think of for this moment.
 
Upvote 0

Forum statistics

Threads
1,214,374
Messages
6,119,159
Members
448,870
Latest member
max_pedreira

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