V
Valeria
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
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