ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   .additem (https://www.excelbanter.com/excel-programming/292013-additem.html)

Robert Couchman[_4_]

.additem
 
Hi all,

i am trying to create a list for a combobox using a
collection, only problem is that the collection is text
and i am trying to use the following:=

for each w in coll
.additem
next w

DOESNT work cause it isnt adding any data, it is just
adding a blank enterty!

can anyone please let me know how??

if it helps the collection is holding data cells
(i, "B").text, cells(i, "D").text


Thank you,

Robert Couchman

Kevin Mitchell

.additem
 
You are just adding blank items because you are not telling the program to
do anything else.

Traditionally you add a value to the combo box by:
combo1.additem "myitem1"
or
combo1.additem variablename

You probably need to add something after your .additem ...perhaps
".additem w"

....haven't tried it ...but just a thought



"Robert Couchman" wrote in message
...
Hi all,

i am trying to create a list for a combobox using a
collection, only problem is that the collection is text
and i am trying to use the following:=

for each w in coll
.additem
next w

DOESNT work cause it isnt adding any data, it is just
adding a blank enterty!

can anyone please let me know how??

if it helps the collection is holding data cells
(i, "B").text, cells(i, "D").text


Thank you,

Robert Couchman




BrianB

.additem
 
You have to tell it what to add. Here is some code that works :-

'------------------------------------------------------
FindForm.BookCombo.Clear
For Each wb In Workbooks()
FindForm.BookCombo.AddItem (wb.Name)
Next
'------------------------------------------------------------

--
Message posted from http://www.ExcelForum.com


Robert Couchman[_4_]

.additem
 
Thank you Bob,

this is much more logical, but i have already got
information in my collection.

the difficult part is trying to get that info out!

my collection holds data from columns B, C, D and only
outputs ""

which means i am calling the data incorrectly, yes??

thank you,

Robert Couchman

'------------------------------------------------------
FindForm.BookCombo.Clear
For Each wb In Workbooks()
FindForm.BookCombo.AddItem (wb.Name)
Next
'---------------------------------------------------------



All times are GMT +1. The time now is 07:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com