Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating listbox Mick[_2_] Excel Discussion (Misc queries) 1 May 14th 08 10:48 PM
Populating combobox/listbox Torstein S. Johnsen[_2_] Excel Programming 1 May 13th 04 09:26 AM
Populating TextBox Value--using ListBox jpendegraft[_15_] Excel Programming 1 May 2nd 04 03:53 AM
Populating a userform 3 col listbox Martin[_13_] Excel Programming 0 April 19th 04 09:49 PM
populating multicolumn listbox with an array instead of... notsureofthatinfo Excel Programming 0 November 5th 03 10:18 PM


All times are GMT +1. The time now is 06:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"