+ Reply to Thread
Results 1 to 7 of 7

Macro to run when item is selected from listbox

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Macro to run when item is selected from listbox

    Hi everybody.
    The macro code below detects whether cell G5 is empty or not and if it's not empty it runs a macro (called "MyMacro")
    However, when that cell gets populated via an item selected from a list-box the macro does not recognize right away that it's populated, only when i double-click on a random cell and then click out does the macro run.
    Is there a way to make the macro as soon as an item is selected from the list box?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to run when item is selected from listbox

    Hi, kosherboy,

    if you use an ActiveX-Component you may use the ListBox_Change-event to trigger the macro - why not use that?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Macro to run when item is selected from listbox

    Hi Holger.
    Thank you. Can you show me how that can be done?

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to run when item is selected from listbox

    Hi, kosherboy,

    I just had the ListFillRange on the sheet, added a listbox from the ActiveX controls, limited it to single select, assigned the ListFilRange, ended the "developer mode", put the code behind the sheet:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Macro to run when item is selected from listbox

    Holger, it worked, thank you!

  6. #6
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Macro to run when item is selected from listbox

    Hi Holger. I ran through some issues with the active X list box so i am now using a form control list box. I plugged in your code into the form control but excel returned an error.
    Can you advise me as to how i can plug your code in to the form control properly?

    *the issue with the active X is that it keeps freezing. I saw online that a lot of people have the same issue and they were told to use form control.
    Last edited by kosherboy; 04-30-2014 at 05:16 PM.

  7. #7
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Macro to run when item is selected from listbox

    Hey Holger, i spent some time and figured out the problem
    See you around

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Listbox selected item not getting properly highlighted
    By KeithDyne in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2021, 10:31 PM
  2. Remove selected item from listbox
    By ChrisMattock in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-28-2014, 08:36 AM
  3. how do I return a HIGHLIGHTED (not selected) item from a ListBox?
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2012, 08:27 AM
  4. Change status of more than one item selected in Listbox
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-29-2012, 05:09 AM
  5. [SOLVED] Need selected item from listbox after double click
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2006, 11:20 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1