+ Reply to Thread
Results 1 to 5 of 5

Populate userform listbox with worksheet ending with specific name

  1. #1
    Registered User
    Join Date
    09-09-2013
    Location
    MAL
    MS-Off Ver
    Excel 2007
    Posts
    22

    Populate userform listbox with worksheet ending with specific name

    Thank you for taking a look at this thread. Here's what I want to achieve.
    1. The vba is stored in my personal A.xls.
    2. Run macro "setWS".
    3. The macro will launch open file dialogbox, let me select another xls file.
    4. It will check the opened file and look for worksheet with name ending in "-New" regardless of upper/lowercase, e.g. A-NEW, B1-NeW, CC-New.
    5. Other worksheets without the -NEW will be ignored.
      1. If there's only 1 worksheet ends with -new, then just set variable wsn to that worksheet name.
      2. If more than 1 worksheets with -new are found, then open the userform with a listbox and a select button.
      3. Populate the worksheet name in the listbox.
      4. I can either double click and select one of the worksheet name in the listbox, or single click on a worksheet, then click Select button. Both actions will do the same thing, setting the selected -New worksheet name to variable wsn.
    6. Once wsn is set, close the userform, and continue with next part of the code.
    7. I try to piece together the code, but this is as far as I go.


    Please Login or Register  to view this content.
    Last edited by Efjoker; 09-24-2014 at 11:08 AM. Reason: Changing title

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Populate userform listbox with worksheet ending with specific name

    Try something like this.

    Please Login or Register  to view this content.
    Userform code
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    09-09-2013
    Location
    MAL
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Populate userform listbox with worksheet ending with specific name

    Thank you for replying, AlphaFrog.

    After the wsn value is set, instead of passing the control to Do_Stuff_With subroutine, I would like to continue processing the next part of code in the same setWS sub. Can this be done?
    Last edited by Efjoker; 09-26-2014 at 07:42 AM.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Populate userform listbox with worksheet ending with specific name

    The Do_Stuff_With subroutine is the next part of your code. Put the next part of your code in that procedure.

  5. #5
    Registered User
    Join Date
    09-09-2013
    Location
    MAL
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Populate userform listbox with worksheet ending with specific name

    Okay, thanks for the advice.

+ 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] Filter worksheet data using 4 dependant comboboxes and populate in 'ListBox' on a userform
    By p_nayak268 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-27-2014, 12:41 PM
  2. Populate VBA Userform Listbox using SQL Recordset
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2013, 06:48 PM
  3. VBA - Populate Listbox based on value selected in another ListBox (On Userform)
    By raaboo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-12-2012, 11:18 AM
  4. Populate userform listbox based on value selected in another listbox
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2012, 05:16 PM
  5. how to populate Listbox on userform
    By kmsoni in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2011, 02:13 PM

Tags for this Thread

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