Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

arrays source dropdown list

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Arrays as the source for a dropdown list

Arrays as the source for a dropdown list

ResolvedVersion 2010

Kevin has attended:
Excel VBA Intro Intermediate course

Arrays as the source for a dropdown list

Hi

This is a just a general query (and probably very straight forward!) at this stage but is it possible to use an array as the source for the contents of a dropdown list and what might the code look like?

Thanks. Kev

RE: Arrays as the source for a dropdown list

Hi Kev

Thanks for getting in touch. Just before I answer that when you use the word "array", are you referring to VBA variable arrays, or another word for a range of cells?

It could have very different answers. I only ask because you've been on the Intro Intermediate course where we don't cover arrays.

Kind regards

Gary Fenn
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Arrays as the source for a dropdown list

Hi Gary

Sorry, range of cells. I was discussing something with a colleague while typing the post! The bigger picture here is:

I want to create a list of people who have indicated their availability on a particular date so they can be allocated, via a dropdown, to one of five locations. If they have already been allocated to a location on that date I still want them to appear in the dropdown for the other four locations but not available for selection.

Thanks. Kev

RE: Arrays as the source for a dropdown list

Hi Kev

Thanks for getting in touch. To put the contents of some cells into a VBA combo box, click on the combo box and look for the RowSource property. You can enter the range or range name in there.

You can also use the Transpose and AddItem methods too, such as in this example:

http://stackoverflow.com/questions/13115034/excel-vba-combobox

To then make them unavailable for selection, you might want to perform validation on what has been selected, e.g. "If ComboBox1 = "Dave" Then MsgBox "Not available on this date"

I hope this helps.

Kind regards

Gary Fenn
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Arrays as the source for a dropdown list

Thanks gary

Kev

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Ctrl+d's double life

Suppose I have a formula in B1 that I wish to copy into B2:B10. I can select B1:B10 then press Ctrl+d to copy the formula down the selected range. Users generally ignore this shortcut in favour of double-clicking on the fill handle to copy down, but Ctrl+d is useful sometimes particularly when there is no data in surrounding columns to guide to how far the double-click method should copy formulae.

Ctrl+d has another use though. When I use the drawing toolbar to draw objects such as Text Boxes, Rectangles and Ovals onto a worksheet, Ctrl+d makes an instant duplicate of selected shapes. For example, I need five Text Boxes the same size. I draw one Text box and adjust it to the size I want, select it, then press Ctrl+d four times to get four identical copies.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.08 secs.