Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a list box that i want to populate from an Excel list. The list
would look something like this: A B Domain A CompName1 Domain A CompName2 Domain A CompName3 Domain A CompName4 Domain B CompName5 Domain B CompName6 Domain C CompName7 Here is the code I am using: 'begin looking for new list items Dim RowIndex As Long Dim StartRow As Long Dim LastRow As Long Dim curCell As Range StartRow = 20 'LastDataRow is a UDF i made that finds the last row with an entry in it. LastRow = LastDataRow("DomainDatabase", 1, StartRow) For RowIndex = StartRow To LastRow Set curCell = Worksheets("DomainDatabase").Cells(RowIndex, 1) 'check to see if the list is empty If Me.lstSeriesName.ListCount = 0 Then 'if it is, add the first item to the list Me.lstSeriesName.AddItem curCell.Value Else 'If the list isn't empty, find out if the value ' in the cell is already in the listbox Dim index As Integer Dim EntryCount As Integer EntryCount = Me.lstSeriesName.ListCount For index = 0 To EntryCount Me.lstSeriesName.ListIndex = index If Not curCell.Value = Me.lstSeriesName.Value Then Me.lstSeriesName.AddItem curCell.Value EntryCount = EntryCount + 1 End If Next index End If Next RowIndex The problem I have is basically the first domain set will resolve properly, while the second and subsequent domains will have multiple listings. The problem appears to be in the following area: For index = 0 To EntryCount Me.lstSeriesName.ListIndex = index If Not curCell.Value = Me.lstSeriesName.Value Then Me.lstSeriesName.AddItem curCell.Value EntryCount = EntryCount + 1 End If Next index Any help here would be great, I am fairly new to loops much less nested loops. Thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
List Duplicates | Excel Worksheet Functions | |||
Duplicates in a list | Excel Discussion (Misc queries) | |||
Condensing a list with duplicates to a list with non-duplicates | Excel Worksheet Functions | |||
Array Formulas - Unique List from List with Duplicates | Excel Discussion (Misc queries) | |||
How to remove duplicates from a list and copy new list to new colu | Excel Worksheet Functions |