Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Below is a listbox code that looks in the range and fills
the combobox with the values. Is there a way to add into the code to ignore cells that = "" (nothing)? And also is there a code that instead of looking in columns (like the below code does), can look for values down rows instead of across columns? For instance in Range A1:A20. Thanx Private Sub UserForm_Initialize() ListBox1.ColumnCount = 1 ListBox1.RowSource = "ab1:ab26" ListBox1.ControlSource = "E20" 'Place the ListIndex into cell E20 ListBox1.BoundColumn = 0 End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Todd,
To omit the blanks, or to use a row as the source, you'd have to loop through the range and use AddItem to add the items to the list box. For example Private Sub UserForm_Initialize() Dim Rng As Range With ListBox1 .ColumnCount = 1 For Each Rng In Range("AB1:AB26").Cells If Rng.Text < "" Then .AddItem Rng.Text End If Next Rng End With .ControlSource = "E20" End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Todd Huttenstine" wrote in message ... Below is a listbox code that looks in the range and fills the combobox with the values. Is there a way to add into the code to ignore cells that = "" (nothing)? And also is there a code that instead of looking in columns (like the below code does), can look for values down rows instead of across columns? For instance in Range A1:A20. Thanx Private Sub UserForm_Initialize() ListBox1.ColumnCount = 1 ListBox1.RowSource = "ab1:ab26" ListBox1.ControlSource = "E20" 'Place the ListIndex into cell E20 ListBox1.BoundColumn = 0 End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding values in different rows/columns | Excel Worksheet Functions | |||
How do I add cell values that are in different rows/columns? | Excel Worksheet Functions | |||
Referencing columns values in rows | Excel Discussion (Misc queries) | |||
Match Values in Rows with Partial Values in Columns | Excel Worksheet Functions | |||
Copy values in columns to rows | Excel Worksheet Functions |