We help IT Professionals succeed at work.

List Box Entries Excel 2010

122 Views
Last Modified: 2017-03-16
I have a simple list box with the following entries.

John
Mary
Ralph
Sue

When I select one of the names in the list box I want it to record in the active worksheet of the active cell.

What code do I need to make this happen?
Comment
Watch Question

Excel & VBA Expert
CERTIFIED EXPERT
Most Valuable Expert 2018
Awarded 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
If it's NOT an ActiveX listbox then you need to do something like

Application.EnableEvents = False

With ActiveSheet.ListBoxes("List Box 1") ' Change the name if necessary
    For lngIndex = 1 To .ListCount
        If .Selected(lngIndex) Then
            ActiveCell.Valuet = .List(lngIndex)
            Exit For
        End If
    Next
End With

Application.EnableEvents = True

Open in new window

ShumsManaging Director/Excel VBA Developer
CERTIFIED EXPERT
Distinguished Expert 2018

Commented:
ActiveCell could be risky, instead just add the cell value in LinkedCell like below image:
LinkedCell

Author

Commented:
Thank you.  Works like a charm.
Subodh Tiwari (Neeraj)Excel & VBA Expert
CERTIFIED EXPERT
Most Valuable Expert 2018
Awarded 2015

Commented:
You're welcome! Glad it worked.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.