+ Reply to Thread
Results 1 to 18 of 18

Help to show multiple columns in a listbox

  1. #1
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Question Help to show multiple columns in a listbox

    Hello,

    I need help to change the below code so that it shows 2 columns of data in the listbox as opposed to just 1 which is what it does currently. Can anyone help?

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Help to show multiple columns in a listbox

    Please attach a sample excel sheet if you have..
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help to show multiple columns in a listbox

    The first thing you need to do is change the ColumnCount property of the listbox to 2.

    You'll then have 2 columns in the listbox, but we would need more information to help you populate them.
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help to show multiple columns in a listbox

    Sorry that was the code for the wrong userform! The userform I am talking about is less complicated I think

    Code is below. I have changed the ColumnCount to 2, the data that needs to go in there is simply from a table column

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help to show multiple columns in a listbox

    Which column does the data for the second column in the listbox come from?

  6. #6
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help to show multiple columns in a listbox

    It's in the same PivotTable. The second column in the same Pivot Table

  7. #7
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help to show multiple columns in a listbox

    Anyone got any ideas on this please?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help to show multiple columns in a listbox

    You don't refer to a pivot table in the posted code so it's kind of hard to work out how to refer to the second column of a pivot table.
    Last edited by Norie; 02-09-2015 at 09:28 AM.

  9. #9
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help to show multiple columns in a listbox

    No sorry the pivot table column has been made into a named range, which is the dd_codes that the code refers to. There might have been an easier way to do it.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help to show multiple columns in a listbox

    If the named range 'dd_codes' refers to the first column of the pivot table and you want to show the first two columns in the listbox this might work.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help to show multiple columns in a listbox

    OK is that to replace any code or just to add onto the end?

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help to show multiple columns in a listbox

    It replaces this code.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help to show multiple columns in a listbox

    Thanks, just tried that and it says invalid use of property?

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help to show multiple columns in a listbox

    What exactly did you try?

  15. #15
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help to show multiple columns in a listbox

    Please Login or Register  to view this content.

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help to show multiple columns in a listbox

    Oops, should be this.
    Please Login or Register  to view this content.

  17. #17
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,280

    Re: Help to show multiple columns in a listbox

    It's
    Please Login or Register  to view this content.
    not just
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  18. #18
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help to show multiple columns in a listbox

    Excellent, that has sorted it.

    Many thanks both of 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. Listbox value to multiple columns
    By rskfriends in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-23-2014, 10:06 AM
  2. VBA Excel Listbox with multiple columns pasting into multiple cells
    By anqTM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-23-2014, 12:57 AM
  3. How to show more columns in a listbox ?
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2012, 02:59 PM
  4. Using VBA to add multiple columns to a listbox
    By talksalot81 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2011, 08:25 AM
  5. [SOLVED] adding multiple columns to a listbox
    By ndm berry in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2005, 05:05 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