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

excel vba populating

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel VBA : Populating a list box with a field

Excel VBA : Populating a list box with a field

ResolvedVersion 2003

Herman has attended:
Excel VBA Intro Intermediate course

Excel VBA : Populating a list box with a field

Hello,

How would I create a list box that would populate the list of HR people in a user forum list box?

Thanks

Herman

RE: Excel VBA : Populating a list box with a field

Hello Herman

Thank you for your question.

The first thing to do would be to type the names of the HR people into a list somewhere within your workbook.

You would then need to write some code that loops through the list, one row at a time; and at each point adds the name in that row to the list box.

The key piece of code that adds the item to the list box would take the form.

Count = ActiveCell.CurrentRegion.Rows.Count

With Me.listbox

For Counter = 2 To Count

.AddItem Worksheets("worksheet name").Cells(Counter, 1)

Next Counter

End With



Hope this is useful

Regards

Stephen

 

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:

Removing border lines on the keyboard

Highlight your cell(s) that have boreders on them and press CTRL + SHIFT + _, this will then remove the border lines.

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.09 secs.