+ Reply to Thread
Results 1 to 5 of 5

Populate a userform listbox with data from another workbook that is closed

  1. #1
    Forum Contributor
    Join Date
    06-07-2014
    Posts
    218

    Populate a userform listbox with data from another workbook that is closed

    Hi folks, I have been trying to populate a userform listbox with data from another workbook that is closed, but no luck!

    I have attached two files - Main and TheDatabase. I would like to achieve the below:

    1. Open "Main.xlsb" file
    2. Click Button1
    3. Userform "frmViewRecords" opens and populates with data found in TheDatabase.xlxs file. To achieve this listbox population, I would like TheDatabase.xlxs file to be opened, populate the ListBox "lstRecords" from the Main.xlsb file and then TheDatabase.xlxs file should be closed without saving changes.
    4. When I click on a line of data from the ListBox in Section A, I want that corresponding data to populate the associated TextBoxes of Section B.

    Can you please assist? You can use whatever corresponding paths apply in your system for the location of TheDatabase.xlsx file when writing/testing the code, however we can assume that the path is C:\Users\ComputerName\Desktop\New folder\TheDatabase.xlsx

    I don't want to use ADO.

    Also, I tried online examples which did not work, such as the below:

    Thanks!

    Please Login or Register  to view this content.
    Last edited by chin67326; 12-21-2015 at 08:42 AM.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Populate a userform listbox with data from another workbook that is closed

    with both files in same Map

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    06-07-2014
    Posts
    218

    Re: Populate a userform listbox with data from another workbook that is closed

    LeoTaxi, thank you very much sir! That is some clever stuff, you make it so simple there.

    What I should have mentioned in my original post, and very important, is the fact that both files cannot be in the same map. For example, the Main file will be in one server e.g. D:/Server1, and TheDatabase file will be in another server e.g. A:/Server2.

    Therefore, is it possible to use your below code:

    HTML Code: 
    and combine it with the below code, so the path address can be entered to locate TheDatabase.xlsx file via the server address, open it, get the data and populate the listbox, and close TheDatabase file, just like the code below? I am not sure why the below code doesn't work for me. I tweaked it but it still leads to a debugging error.

    Appreciated once again.

    HTML Code: 
    Last edited by chin67326; 12-17-2015 at 12:28 AM.

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Populate a userform listbox with data from another workbook that is closed

    Just change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    exemple
    Please Login or Register  to view this content.
    Kind regards
    Leo
    Last edited by LeoTaxi; 12-17-2015 at 05:42 AM.

  5. #5
    Forum Contributor
    Join Date
    06-07-2014
    Posts
    218

    Re: Populate a userform listbox with data from another workbook that is closed

    Quote Originally Posted by LeoTaxi View Post
    Just change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    exemple
    Please Login or Register  to view this content.
    Kind regards
    Leo

    Leo, I am happy - THIS WORKED LIKE A CHARM!

    Thanks for your help and Happy Christmas to you!

+ 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. Replies: 1
    Last Post: 05-30-2015, 12:15 PM
  2. populate listbox in userform in MSword with excel data
    By dreojs16 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2015, 10:32 AM
  3. [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
  4. [SOLVED] Filling multiselect listbox based on closed workbook data
    By FKurzhals in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-23-2013, 02:56 PM
  5. VBA userform listbox populate data entered from comboboxes
    By Hilton1982 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2012, 11:29 PM
  6. Populate a comboxbox and Listbox in a excel userform with an sql table data
    By abhay_547 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2010, 04:58 PM
  7. Getting Data from closed workbook into userform
    By www.butterflysystems.co.uk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-19-2006, 05:00 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