Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 19th, 2008, 09:10 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Array as Source for List Box

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.

 
Old March 24th, 2008, 05:43 PM
Authorized User
 
Join Date: Mar 2008
Posts: 35
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Coby,
for what it's worth after a whole month from your post... put the following in the Userform code module.
Code:
Dim arr as Variant
arr = Array("AA","BB","CC")
ListBox1.List = arr
The Following User Says Thank You to tstav For This Useful Post:
bum94587 (June 5th, 2013)
 
Old June 5th, 2013, 05:07 PM
Registered User
 
Join Date: Jun 2013
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks, it works & saved me a lot of time!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
SQL from 3 tables as source for List Box? Loralee Access 2 February 16th, 2005 12:47 AM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.