+ Reply to Thread
Results 1 to 3 of 3

Variable listbox for userform

  1. #1
    Registered User
    Join Date
    01-19-2009
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    69

    Variable listbox for userform

    Hi I am after some help trying to make my code a little bit simpler.

    In my workbook I currently have 40+ tabs and depending on what I am doing I only want to show some of the tabs, I some code for a listbox and currently I am copying the code for each of the listboxes I have. I have attempted to write some code to make the listbox variable within a loop but it doesnt work, any help would be appreciated.

    all my code is on the command button1 in the VBA screen
    Attached Files Attached Files
    Last edited by sput_sput; 07-27-2023 at 08:52 AM.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Variable listbox for userform

    Try the attached approach - all the listbox choices are intercepted by the Class module.
    As you make a selection in the listbox the sheet will unhide/hide.
    Attached Files Attached Files
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    01-19-2009
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    69

    Re: Variable listbox for userform

    Thanks that works perfectly.

+ 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. Trying to use RowSource in a UserForm ListBox, referencing a sheet name by a variable
    By Spielberg in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 02-07-2023, 03:15 PM
  2. Replies: 1
    Last Post: 04-12-2022, 04:38 PM
  3. [SOLVED] if anything in listbox select first item, if listbox empty do nothing (listbox in userform
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 12:49 PM
  4. [SOLVED] copy contents of userform listbox to another userform listbox
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2014, 11:39 AM
  5. How to pass a variable value from a Userform listbox/spinbutton to another sub
    By max3732 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-13-2014, 01:01 PM
  6. Transfer Data From One Userform Listbox to Another Userform Listbox with 11 columns
    By sparkoft in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-18-2013, 10:54 AM
  7. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM

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