list box

reddcannon

Board Regular
Joined
Aug 11, 2011
Messages
118
I have a list box, and when the form is closed and reopened, I would like it to automatically return to the first item on the list. But it goes back to the last item chose. is there a way to make it start at the first item
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
My sincere apologies, I meant to say combo box and open and close means, when I close the spreadsheet and then reopen it, I want the combo box (sorry not list box) to start at the first item on the list (since it is the most used)
 
Upvote 0
It's the same method/property.


Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
    If Sheet1.ListBox1.ListCount > 0 Then
        Sheet1.ListBox1.ListIndex = 0
    End If
    
    If Sheet1.ComboBox1.ListCount > 0 Then
        [COLOR=royalblue]Sheet1.ComboBox1.ListIndex = 0
[/COLOR]    End If
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,814
Members
452,945
Latest member
Bib195

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