+ Reply to Thread
Results 1 to 3 of 3

run code if anything selected in any listbox

  1. #1
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    116

    run code if anything selected in any listbox

    Hello,

    I have ten multiselect listboxes on a userform. Is there a way to have code run if anything is selected in any of the listboxes without having to create private subs for each listbox?

    I am trying to avoid:

    Private Sub listbox1_change()
    code...
    End Sub

    Private Sub listbox2_change()
    code...
    End Sub

    ...

    Private Sub listbox10_change()
    code...
    End Sub


    and so forth .

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: run code if anything selected in any listbox

    you could create one routine that takes a listbox parameter and then call that from each change event or you could use a class module
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    116

    Re: run code if anything selected in any listbox

    Thanks, JosephP! Creating one routine to run on each change event should work. I guess I'm getting tired, that probably should have come to my mind.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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