how to find out when a ListBox is populated or select it
Hi Bob,
it works very well, I am really learning a lot from you,
many thanks!
Kind regards,
Valeria
-----Original Message-----
Valeria,
Look at the Listbox ListCount property. This will return
the number of items
in the listbox
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Valeria" wrote in
message
...
Dear experts,
I am working on a userform.
I am inputting data from different text boxes into a
ListBox via clicking a button, and then transfering the
combined data from this ListBox into a macro via
clicking
a second button.
I want the userform to tell the user that he needs to
input some data if none was entered, so I wrote this
code:
If ListBox4.ListIndex = -1 Then
MsgBox "Please enter the product data before clicking on
this button"
Exit Sub
End If
The problem I have is that as at the end none of the
items
in ListBox4 is selected (items are just added via
clicking
the button), even if the ListBox is populated the
ListIndex returns -1.
Is there a way I can select the ListBox, or get around
this problem?
Many thanks in advance for your help!
Kind regards,
Valeria
.
|