+ Reply to Thread
Results 1 to 6 of 6

Retreive 2nd column from combo box selected value

  1. #1
    Registered User
    Join Date
    07-22-2019
    Location
    Omaha
    MS-Off Ver
    2016
    Posts
    3

    Retreive 2nd column from combo box selected value

    Trying to check the 2nd column value of a combo box SELECTED value. I can't figure this out.
    Returns 2nd column of 1st value.

    If Me.cHeadacheRack.Column(1,0) = "XYZ" Then
    msgbox(Me.cHeadacheRack.Column(1,0))
    End If

    I can get the first value in the combo, but how do I get the selected value?
    Last edited by tkraemer42; 07-22-2019 at 03:58 PM. Reason: More info

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Retreive 2nd column from combo box selected value

    It's a bit difficult to help you without specifics.

    But assuming you have Combobox1 property set as following...

    BoundColumn = 1
    ColumnCount = 2

    Something like below to access Column 2's value.
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    07-22-2019
    Location
    Omaha
    MS-Off Ver
    2016
    Posts
    3

    Re: Retreive 2nd column from combo box selected value

    Yes, bound =1 and column count =2. I copied your code and changed the combo box name to match my form. I get the same error.

    This function triggers off the change of the combo box. It reads the second column and will return a value depending on the 2nd column.

    Attachment 633649

    Please Login or Register  to view this content.
    Last edited by tkraemer42; 07-22-2019 at 03:39 PM. Reason: used code tags

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Retreive 2nd column from combo box selected value

    What is the exact error code? And which line produces it?

    See attached sample.

    Edit: Where is your function stored? Is it in UserForm module?
    Also, my code was just showing how to access column 2 value and did not use any error handling.
    Note that when there is no value selected or invalid value typed for combobox1, you'll need to perform error handling.
    As column 2 value is only accessible when valid value is selected for the combobox.

    EDIT2: Please use code tag (# button) to post your code(s).
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-22-2019
    Location
    Omaha
    MS-Off Ver
    2016
    Posts
    3

    Re: Retreive 2nd column from combo box selected value

    That was it! This function is triggered each time the combo box changes, which includes loading the combo box. Each additem triggered the change event, which triggered the function to run without a selected value. I added an error handler that bypasses the retrieval of data if combobox.value <> ""

    Thank you!

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Retreive 2nd column from combo box selected value

    You are welcome

+ 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] Delete the all chosed column which is selected in combo box!!!!!!!!!!!!!
    By END93 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2016, 12:25 PM
  2. Store and retreive values of selected cells
    By lovallee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-16-2014, 06:59 PM
  3. Populate Combo box 2 based on Selected item in Combo box 1
    By Vasu_XL in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2014, 07:45 AM
  4. [SOLVED] List in Combo Box, when new item is selected put todays date in the adjacent column
    By Antligen in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-03-2014, 10:30 AM
  5. [SOLVED] Excel 2010 VBA – Combo Box Options– Clear cell/box in 2nd Combo when 1st Combo selected
    By theshybutterfly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2013, 07:25 PM
  6. Replies: 5
    Last Post: 02-10-2009, 04:09 AM
  7. [SOLVED] How can I retreive rows from one column?
    By Miriam in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-19-2006, 12:30 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