Button to change selection in ListBox
Results 1 to 4 of 4

Thread: Button to change selection in ListBox
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2016
    Posts
    44
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Button to change selection in ListBox

    Hey everyone, I'm facing the following problem:

    I have a table where Column A gives me Names and column B gives me the status "done" or "ongoing".
    I have a ListBox that populates with all names from column A.
    I want to be able to select an item in the List and click a button to change the status in column B for the selected name to "DONE".

    There are no userforms.

    How would the code for the Button click look like?

    Thanks!

  2. #2
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,244
    Post Thanks / Like
    Mentioned
    49 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Button to change selection in ListBox

    If you have a listbox and a commanbutton of ActiveX controls




    Use this:

    Code:
    Private Sub CommandButton1_Click()
        If ListBox1.ListIndex = -1 Then
            MsgBox "Select a name"
        Else
            Cells(ListBox1.ListIndex + 2, "B").Value = "done"
        End If
    End Sub
    Regards Dante Amor

  3. #3
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,439
    Post Thanks / Like
    Mentioned
    443 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Button to change selection in ListBox

    Cross posted https://www.excelforum.com/excel-pro...a-listbox.html

    While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
    This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  4. #4
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,244
    Post Thanks / Like
    Mentioned
    49 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Button to change selection in ListBox

    Regards Dante Amor

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •