![]() |
VBA ListBox
Can anyone please tell me how to check that the user has made a selection in
a VBA ListBox - I need to warn them if no selection has been made Thanks TAM |
VBA ListBox
If no item has been selected in the listbox, the ListIndex
property will be -1. E.g., If Me.ListBox1.ListIndex = -1 Then MsgBox "You must select an item" End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "TAM" wrote in message t... Can anyone please tell me how to check that the user has made a selection in a VBA ListBox - I need to warn them if no selection has been made Thanks TAM |
VBA ListBox
Here is some code for a userform listbox
Dim i As Long Dim fSelected As Boolean fSelected = False With Me.ListBox1 For i = 1 To .ListCount If .Selected(i) Then fSelected = True Exit For End If Next i End With If Not fSelected Then MsgBox "Nothing selected" End If -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "TAM" wrote in message t... Can anyone please tell me how to check that the user has made a selection in a VBA ListBox - I need to warn them if no selection has been made Thanks TAM |
VBA ListBox
Many thanks for your help
"TAM" wrote in message t... Can anyone please tell me how to check that the user has made a selection in a VBA ListBox - I need to warn them if no selection has been made Thanks TAM |
VBA ListBox
Check the ListIndex property. It will be -1 if no selection has been
made. For more, check the VBA help. -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , says... Can anyone please tell me how to check that the user has made a selection in a VBA ListBox - I need to warn them if no selection has been made Thanks TAM |
All times are GMT +1. The time now is 07:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com