+ Reply to Thread
Results 1 to 6 of 6

Display two columns in combobox

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-14-2015
    Location
    Mexico
    MS-Off Ver
    365
    Posts
    285

    Display two columns in combobox

    I have the following code that shows in combobox "cboCust" the information of ColumnB, how can I modify the code to show in combobox ColumnB and C?


    Private Sub UserForm_Initialize()
    
    'multiple columns combobox
    
        With cboCust
            .ColumnCount = 2
            .List = Range("tblClients").ListObject.ListColumns(2).DataBodyRange.Value
            .ColumnWidths = "70 pt;30 pt"
        End With
    
    End Sub

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

    Re: Display two columns in combobox

    .List = ActiveSheet.ListObjects(1).DataBodyRange.Columns("B:C").Value
    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
    Forum Contributor
    Join Date
    03-14-2015
    Location
    Mexico
    MS-Off Ver
    365
    Posts
    285

    Re: Display two columns in combobox

    That worked great thank you so much!

  4. #4
    Forum Contributor
    Join Date
    03-14-2015
    Location
    Mexico
    MS-Off Ver
    365
    Posts
    285

    Re: Display two columns in combobox

    AlphaFrog, can you please help me to adjust the code if I want to select non-adjacent columns such as B, M and T?

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,697

    Re: Display two columns in combobox

    One way would be to set the ColumnCount to 19 (Column B to Column T) and set the ColumnWidths for the Columns not needed to 0.
    .ColumnWidths = "70;0;0;0;0;0;0;0;0;0;0;30;0;0;0;0;0;0;45"
    Or you can copy the needed Columns into another Sheet (Hidden or VeryHidden?) and use that.

  6. #6
    Forum Contributor
    Join Date
    03-14-2015
    Location
    Mexico
    MS-Off Ver
    365
    Posts
    285

    Re: Display two columns in combobox

    thank you that worked

+ 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] Combobox on a userform does not display the two columns
    By necalabria in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2019, 07:31 PM
  2. [SOLVED] Combobox display information?
    By bralew in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2016, 05:35 AM
  3. Userform Combobox to populate form: Can I change the order of the columns in the combobox?
    By CraigWiggins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2014, 12:14 PM
  4. [SOLVED] New to Forms-Display a blank combobox but have one column in it restricted to a combobox?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-14-2013, 09:04 PM
  5. display the results from range of columns when combobox is selected
    By Anchal in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-25-2013, 07:33 AM
  6. ComboBox display
    By Jakes in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2011, 05:41 AM
  7. [SOLVED] MultiColumn ComboBox Value set/display
    By Jim Zeeb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-13-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