Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to find out when a ListBox is populated or select it
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to find out when a ListBox is populated or select it
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
find last populated cell in range of cells | Excel Worksheet Functions | |||
Find the first or last populated column in a range | Excel Worksheet Functions | |||
I need to select some values in a Listbox???? | Excel Programming | |||
excel - ListBox multiple Select | Excel Programming | |||
Select from table and listbox | Excel Programming |