+ Reply to Thread
Results 1 to 7 of 7

Creating/Populating TABLE (NEW) from an OLD TABLE base on ListBox choices

  1. #1
    Registered User
    Join Date
    09-24-2013
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    24

    Question Creating/Populating TABLE (NEW) from an OLD TABLE base on ListBox choices

    Hi everyone
    I'm confused about picking choices from a ListBox (which are the column Names of a TABLE ) and creating a NEW TABLE based on this choices. I'm doing this because the Maintenance Director will not want to print the whole Worksheet everytime but he wants to be able to choose the columns then print just those columns.

    I created a Userform to get the Columns the USER will want to print but at this point I don't know how to manipulate the column names to create the Table (In Sheet2 perhaps) then print it. I read an article in the NET about Converting a Range to a Table then picking parts of that Table to "construct" the new Worksheet but again I'm very confused. I'll appreciate any suggestions. (Many of the code statements is from the NET and I modified it to work for my Application)
    Thanks

    Sample of the Worksheet:
    Worksheet.JPG

    The UserForm:
    PrintColumns.JPG

    The CODE:

    Please Login or Register  to view this content.
    Last edited by Gilcano; 12-03-2015 at 02:05 PM.

  2. #2
    Registered User
    Join Date
    09-24-2013
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Creating/Populating TABLE (NEW) from an OLD TABLE base on ListBox choices

    I guess no one has done this...

  3. #3
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Creating/Populating TABLE (NEW) from an OLD TABLE base on ListBox choices

    Hi @Gilcano

    I've scratched your code a bit, cause I found some inconsistencies.

    try it and coment us.

    Please Login or Register  to view this content.
    Barriers are there for those who don't want to dream

  4. #4
    Registered User
    Join Date
    09-24-2013
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Creating/Populating TABLE (NEW) from an OLD TABLE base on ListBox choices

    @vichopalacios, I really appreciate your help as I mentioned I'm learning VBA and sometimes wants to get results too fast and that will lead to inconsistencies like you mentioned. I apologize but wants to get this done. I pasted your code and I'm getting a Run-Time Error 'Could not get the Selected Property. Invalid Argument. when adding the items from Listbox1 (MyWsheetCol) to Listbox2 (MyWSheet2). Thanks for helping me.

    I like your way of populating the ListBox1 (MyWSheetCol) with the headers in Sheet1. With this method you could do any worksheet if you pass the Worksheet Name.....Very nice.


    Error.JPG
    Error1.JPG
    Last edited by Gilcano; 12-04-2015 at 10:34 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Creating/Populating TABLE (NEW) from an OLD TABLE base on ListBox choices

    Hi Gilcano

    I can't see anything wrong with the code, I tested and it's working fine to me
    I'm attaching a sample file to show you it's OK

    Perhaps you changed something when pasting...
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    09-24-2013
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Creating/Populating TABLE (NEW) from an OLD TABLE base on ListBox choices

    Thanks a lot, found the problem. My ListBox1 (MyWSheetCol) MultiSelect property was set to fmMultiSelectMulti instead of fmMultiSelectSingle.

    ThumbsUp.jpg

  7. #7
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Creating/Populating TABLE (NEW) from an OLD TABLE base on ListBox choices

    glad to know it was helpfull for you
    you are wdlcome
    good luck


    Vicho

+ 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: 9
    Last Post: 12-03-2014, 06:17 PM
  2. Populating listbox values of userform dynamically in the Access table fields
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-07-2014, 06:52 AM
  3. populating cells on a table using data from another table
    By richie2711 in forum Excel General
    Replies: 1
    Last Post: 07-21-2013, 07:13 PM
  4. Creating a table to accept Data Base data
    By Cjax in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2011, 11:18 AM
  5. Populating a table based on values in another table
    By Bri in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-25-2006, 09:30 PM
  6. Populating a table with filtered result of another table
    By pikakathy in forum Excel General
    Replies: 7
    Last Post: 01-10-2006, 08:04 PM
  7. VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox)
    By modjoe23 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2005, 09:35 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