PC Review


Reply
Thread Tools Rate Thread

Array as Source for List Box

 
 
Coby
Guest
Posts: n/a
 
      20th Feb 2008
Does anyone know if it is possible to set the row source for a list
box to an array rather than a range of cells?


I am mainly trying to filter out certain rows from the list box.

I Access it is simple because an Sql query with a Where clause does
the trick by committing a recordset much like an array to the list
box.

I am not sure how to do this using the list box object in Excel,
however.

I had also thought of just going with the range of cells rather than
an array if I had to, then just running a loop to remove items from
the list?

I tried both scenarios and have had no luck.

Thanks for sharing any knowledge you may have on this.

Coby.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      20th Feb 2008
Rowsource requires a range.

But you could use:
me.listbox1.list = myArray

Where myArray is your array.

Coby wrote:
>
> Does anyone know if it is possible to set the row source for a list
> box to an array rather than a range of cells?
>
> I am mainly trying to filter out certain rows from the list box.
>
> I Access it is simple because an Sql query with a Where clause does
> the trick by committing a recordset much like an array to the list
> box.
>
> I am not sure how to do this using the list box object in Excel,
> however.
>
> I had also thought of just going with the range of cells rather than
> an array if I had to, then just running a loop to remove items from
> the list?
>
> I tried both scenarios and have had no luck.
>
> Thanks for sharing any knowledge you may have on this.
>
> Coby.


--

Dave Peterson
 
Reply With Quote
 
lesleyann76@gmail.com
Guest
Posts: n/a
 
      20th Feb 2008
On Feb 19, 5:23 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> Rowsource requires a range.
>
> But you could use:
> me.listbox1.list = myArray
>
> Where myArray is your array.
>
>
>
> Coby wrote:
>
> > Does anyone know if it is possible to set the row source for a list
> > box to an array rather than a range of cells?

>
> > I am mainly trying to filter out certain rows from the list box.

>
> > I Access it is simple because an Sql query with a Where clause does
> > the trick by committing a recordset much like an array to the list
> > box.

>
> > I am not sure how to do this using the list box object in Excel,
> > however.

>
> > I had also thought of just going with the range of cells rather than
> > an array if I had to, then just running a loop to remove items from
> > the list?

>
> > I tried both scenarios and have had no luck.

>
> > Thanks for sharing any knowledge you may have on this.

>
> > Coby.

>
> --
>
> Dave Peterson


Great! I wasn't even really clear on the ways to populate the list
box.
Consequently, I have only been using the row source property and was
unaware of other ways to fill that list.

I am going give that a shot now.

Thank, Dave
Coby.
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      20th Feb 2008
You could loop through the range, too.

dim myCell as range
dim myRng as range
set myrng = worksheets("sheet999").range("a1:a13")

for each mycell in myrng.cells
if mycell.value > 10 then
me.listbox1.additem mycell.value
end if
next mycell

(for instance)

(E-Mail Removed) wrote:
>
> On Feb 19, 5:23 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > Rowsource requires a range.
> >
> > But you could use:
> > me.listbox1.list = myArray
> >
> > Where myArray is your array.
> >
> >
> >
> > Coby wrote:
> >
> > > Does anyone know if it is possible to set the row source for a list
> > > box to an array rather than a range of cells?

> >
> > > I am mainly trying to filter out certain rows from the list box.

> >
> > > I Access it is simple because an Sql query with a Where clause does
> > > the trick by committing a recordset much like an array to the list
> > > box.

> >
> > > I am not sure how to do this using the list box object in Excel,
> > > however.

> >
> > > I had also thought of just going with the range of cells rather than
> > > an array if I had to, then just running a loop to remove items from
> > > the list?

> >
> > > I tried both scenarios and have had no luck.

> >
> > > Thanks for sharing any knowledge you may have on this.

> >
> > > Coby.

> >
> > --
> >
> > Dave Peterson

>
> Great! I wasn't even really clear on the ways to populate the list
> box.
> Consequently, I have only been using the row source property and was
> unaware of other ways to fill that list.
>
> I am going give that a shot now.
>
> Thank, Dave
> Coby.


--

Dave Peterson
 
Reply With Quote
 
lesleyann76@gmail.com
Guest
Posts: n/a
 
      20th Feb 2008
On Feb 19, 6:30 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> You could loop through the range, too.
>
> dim myCell as range
> dim myRng as range
> set myrng = worksheets("sheet999").range("a1:a13")
>
> for each mycell in myrng.cells
> if mycell.value > 10 then
> me.listbox1.additem mycell.value
> end if
> next mycell
>
> (for instance)
>
>
>
> lesleyan...@gmail.com wrote:
>
> > On Feb 19, 5:23 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > > Rowsource requires a range.

>
> > > But you could use:
> > > me.listbox1.list = myArray

>
> > > Where myArray is your array.

>
> > > Coby wrote:

>
> > > > Does anyone know if it is possible to set the row source for a list
> > > > box to an array rather than a range of cells?

>
> > > > I am mainly trying to filter out certain rows from the list box.

>
> > > > I Access it is simple because an Sql query with a Where clause does
> > > > the trick by committing a recordset much like an array to the list
> > > > box.

>
> > > > I am not sure how to do this using the list box object in Excel,
> > > > however.

>
> > > > I had also thought of just going with the range of cells rather than
> > > > an array if I had to, then just running a loop to remove items from
> > > > the list?

>
> > > > I tried both scenarios and have had no luck.

>
> > > > Thanks for sharing any knowledge you may have on this.

>
> > > > Coby.

>
> > > --

>
> > > Dave Peterson

>
> > Great! I wasn't even really clear on the ways to populate the list
> > box.
> > Consequently, I have only been using the row source property and was
> > unaware of other ways to fill that list.

>
> > I am going give that a shot now.

>
> > Thank, Dave
> > Coby.

>
> --
>
> Dave Peterson


I like that even better. I just tested that out an will work great
for what I am doing.
Thanks, again.
Coby.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Array for Data Source John Michl Microsoft Excel Charting 1 17th Mar 2006 07:31 PM
Array as chart series data source =?Utf-8?B?TWl0Y2g=?= Microsoft Excel Programming 1 19th Apr 2005 10:59 PM
Datagrid source= datarow array =?Utf-8?B?cm9kY2hhcg==?= Microsoft Dot NET 6 14th Sep 2004 09:21 AM
Adding an Array to an Array List Jack Addington Microsoft C# .NET 2 13th Sep 2004 04:06 PM
Re: Named array as a data source Jon Peltier Microsoft Excel Charting 0 21st Jul 2004 05:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:39 PM.