#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default listbox

I'm sure you are not an idiot; just a newbee to VBA.

O.K. there are 2 types of controls. One type is the Forms Controls and the
other is ActiveX controls. Both are almost identical in their purpose but
they operate differently. ActiveX controls are the later technology and I
think that the Forms controls are only there to keep xl backward compatible.
I think that ActiveX controls started with xl2000 but Ill stand correcting
on that but they have certainly been around since xl2002.

In xl 2007 you will see both types in the drop down when you click on Insert
Controls.

In earlier versions of xl, to see the Forms controls, you need the Forms
tool bar visible. To see the ActiveX controls you need the Control Toolbox
tool bar visible.

I just tested your code and it appears that you have created your List Box
from the Forms tool bar and of course the code is for ActiveX controls and
does not work on on Forms Controls. There are a number of advantages to using
the ActiveX controls so rather than alter the code to work with Forms
controls Ill try to explain how to create an ActiveX control and set its
properties.

Click on the List box icon and then on the worksheet and drag the list box
out to the required size. (Same as for the Forms controls). Note the icon on
the toolbar that looks like a blue set square, pencil and ruler. It is called
Design Mode. It automatically turns on when you create the list box but more
on Design Mode later.

Right click on the list box after you have set its size (Note Design Mode
needs to be on) and then select Properties. The top of the list is the list
box name which is user changeable. It is this name which you use to refer to
the control throughout your VBA code. Check out the other properties
including Multi select.

Before you can use the list box, turn off Design Mode. (Click on the icon.).
Now at any time you want to make changes to the properties, you need to turn
design mode on.

Now turn design mode on and this time when you right click, select View
Code. The VBA editor will open and place a private sub name and end sub. Note
in the Project explorer that the code is attached to the Sheet name on which
the list box has been inserted. Code that you want to run when the user
selects a value in the list box is inserted here. However, it does not
operate with multi list boxes because it would not know when the user has
finished selecting. The code you have for multi select can be in a Module.

Try the above and get back to me if you have any further questions.

Also what version of xl you are using? (It is a good idea to always include
it on requests to this forum.)

Regards,

OssieMac


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
userform listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
avoiding duplicates in listbox (added from another listbox) KR Excel Programming 4 March 14th 06 08:17 PM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


All times are GMT +1. The time now is 10:58 AM.

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

About Us

"It's about Microsoft Excel"