Avatar of William C Johnson
William C JohnsonFlag for United States of America

asked on 

List Box Entries Excel 2010

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?
Microsoft OfficeMicrosoft ExcelVBA

Avatar of undefined
Last Comment
Subodh Tiwari (Neeraj)
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

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

Avatar of Shums Faruk
Shums Faruk
Flag of India image

ActiveCell could be risky, instead just add the cell value in LinkedCell like below image:
User generated image
Avatar of William C Johnson

ASKER

Thank you.  Works like a charm.
You're welcome! Glad it worked.
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo