Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Martin
 
Posts: n/a
Default Filling a List Box in Excel from an Array

Hope someone can help. I have a listbox in excel which I am trying to
populate from an array. The array is picking up certain values from a sheet
depending on a previous value selected in another list box. I currently have
the array code in a module.

regards,
Martin
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default Filling a List Box in Excel from an Array

As an example

For i = LBound(ary) To UBound(ary)
Listbox1.AddItem ary(i)
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Martin" wrote in message
...
Hope someone can help. I have a listbox in excel which I am trying to
populate from an array. The array is picking up certain values from a

sheet
depending on a previous value selected in another list box. I currently

have
the array code in a module.

regards,
Martin



  #3   Report Post  
Andy Pope
 
Posts: n/a
Default Filling a List Box in Excel from an Array

Another example.

Dim strArray(2) As String

strArray(0) = "X"
strArray(1) = "Y"
strArray(2) = "Z"
ListBox1.List = strArray

Cheers
Andy

Martin wrote:
Hope someone can help. I have a listbox in excel which I am trying to
populate from an array. The array is picking up certain values from a sheet
depending on a previous value selected in another list box. I currently have
the array code in a module.

regards,
Martin


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #4   Report Post  
Martin
 
Posts: n/a
Default Filling a List Box in Excel from an Array

Hi Bob,

I have done the below but having read other threads is it not possible to
create a dropdown in a worksheet using the control box and then add items
using VBA?? I am having to reference the control as follows

worksheets("Main").shapes("List Box 2").AddItem UniArray(transnumber)

I get an 'Object does not support property or method' runtime error. Is the
only way around this to create a dropdown via code?

"Bob Phillips" wrote:

As an example

For i = LBound(ary) To UBound(ary)
Listbox1.AddItem ary(i)
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Martin" wrote in message
...
Hope someone can help. I have a listbox in excel which I am trying to
populate from an array. The array is picking up certain values from a

sheet
depending on a previous value selected in another list box. I currently

have
the array code in a module.

regards,
Martin




  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default Filling a List Box in Excel from an Array

Martin,

If you added the control from the controls toolbox, you need to use

worksheets("Main").ListBox2.AddItem UniArray(transnumber)

or

worksheets("Main").oleobjects("ListBox2").object.A ddItem
UniArray(transnumber)



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Martin" wrote in message
...
Hi Bob,

I have done the below but having read other threads is it not possible to
create a dropdown in a worksheet using the control box and then add items
using VBA?? I am having to reference the control as follows

worksheets("Main").shapes("List Box 2").AddItem UniArray(transnumber)

I get an 'Object does not support property or method' runtime error. Is

the
only way around this to create a dropdown via code?

"Bob Phillips" wrote:

As an example

For i = LBound(ary) To UBound(ary)
Listbox1.AddItem ary(i)
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Martin" wrote in message
...
Hope someone can help. I have a listbox in excel which I am trying to
populate from an array. The array is picking up certain values from a

sheet
depending on a previous value selected in another list box. I

currently
have
the array code in a module.

regards,
Martin






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
Excel array formulas Les Gordon Excel Discussion (Misc queries) 1 September 3rd 05 04:12 PM
Can't publish Excel list to Sharepoint LeslieR Excel Discussion (Misc queries) 4 July 20th 05 08:59 PM
Excel List range, filter arrows disappeared andrew Excel Discussion (Misc queries) 3 April 1st 05 11:30 PM
Excel 2003: Match one list against another and highlight differenc smithers2002 Excel Worksheet Functions 1 January 11th 05 03:22 PM
Excel Auto Filter: WHY'S SORT @ TOP OF LIST? WHEN I KEY TO "SHOW . Dan W Excel Worksheet Functions 0 December 1st 04 03:53 PM


All times are GMT +1. The time now is 07:49 AM.

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"