Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Populating a ListBox
I'm sure this is probably pretty simple, but how do I
populate a ListBox with only the populated cells in a worksheet? For example: Column A Column B Column C Column D 2.3 45 23.98 43.981 90 45.877 32.2 3 The ListBox would show all of these numbers using the first row as column headers. The number of rows is different everytime, that's why I can't just specify a range within the ListBox. Any help would be appreciated |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Populating a ListBox
It will take a bit of coding to do it, but here is the
approach to take. First you need to identify the size of the range. It must have a known start point say A3 assign a row vaiable based on activecell.row. Use Activesheet.range("A65536").select to go to the bottom of the sheet. Then Selection.End (xlup).select to find the bottom of the list of data. Then use a=activecell.row to assign the row number to a variable a. Now you know the start row as 4, and the bottom row as the value in a. The number of columns I presume are fixed and hence known. The total number of pieces of data is then a*the number of columns. You then need to assign each value to a variable and use that variable to poulate the listbx using a for to command, and using the activecell.offset to move from one cell to the next to get each pice of data and then placing that piece of data into the listbox using listbox.add and the count value from above to set the number of rows required for the listbox. Hope this gets you started DavidC -----Original Message----- I'm sure this is probably pretty simple, but how do I populate a ListBox with only the populated cells in a worksheet? For example: Column A Column B Column C Column D 2.3 45 23.98 43.981 90 45.877 32.2 3 The ListBox would show all of these numbers using the first row as column headers. The number of rows is different everytime, that's why I can't just specify a range within the ListBox. Any help would be appreciated . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Populating listbox | Excel Discussion (Misc queries) | |||
Populating combobox/listbox | Excel Programming | |||
Populating TextBox Value--using ListBox | Excel Programming | |||
Populating a userform 3 col listbox | Excel Programming | |||
populating multicolumn listbox with an array instead of... | Excel Programming |