+ Reply to Thread
Results 1 to 13 of 13

combobox with two columns?

  1. #1
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Question combobox with two columns?

    i have this code to populate a combobox

    Please Login or Register  to view this content.

    but i want to populate a combobox with both data from b column and c column.

    how do i do this?

    in b column i have first name
    in c column i have last name

    in the combobox i want to show full name

    and it is important that the combobox updates when another row of names is added... so i cant have fix range.

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

    Re: combobox with two columns?

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

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

    Re: combobox with two columns?

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  4. #4
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: combobox with two columns?

    okey, wont happen again.

  5. #5
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: combobox with two columns?

    Quote Originally Posted by Norie View Post
    Try this.
    Please Login or Register  to view this content.
    This one did not work.

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

    Re: combobox with two columns?

    In what way didn't it work?

    Did the original code work to add the first names to the combobox?

  7. #7
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: combobox with two columns?

    Quote Originally Posted by Norie View Post
    In what way didn't it work?

    Did the original code work to add the first names to the combobox?
    It dident work, i got an error that says something about "object does not suppor the property of the method" (translated from swedish)

    see screenshot : http://prntscr.com/ct1rl4

    the original code works fine to just fetch the column B data into the combobox

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: combobox with two columns?

    There is a "t" at the end of Offset that is missing in post #2
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  9. #9
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: combobox with two columns?

    haha, that was the issue.

    Thanks for your help!!
    Works perfectly now

  10. #10
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: combobox with two columns?

    Ok im stuck again lol

    that code that i got working now sadly made my delete row code fail.

    Please Login or Register  to view this content.
    this code is suppose to delete the row of the value i pick in the combobox

    but now when i am using this code
    Please Login or Register  to view this content.
    to populate the combobox
    the value in the combobox is not matched to a singel value in column B.

    I can not see how to solve this easily?
    like if column B value and column C value matches (including a " " ) then delete....
    or is there another solution?

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

    Re: combobox with two columns?

    In the delete code instead of just looking for a match in column B look for a match in column B & " " & column C.
    Please Login or Register  to view this content.

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,356

    Re: combobox with two columns?

    Some remarks.

    1. Avoid looping too many rows.
    2. It's good practice when deleting rows to work from bottom to top to avoid unwanted results (even though in this case there's probably only 1 row to delete).
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  13. #13
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: combobox with two columns?

    Quote Originally Posted by Norie View Post
    In the delete code instead of just looking for a match in column B look for a match in column B & " " & column C.
    Please Login or Register  to view this content.
    great
    tried to do this but used the wrong commands.
    this works good!

+ 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] Add data Combobox Error for certain columns
    By Faridwahidi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-21-2015, 09:54 AM
  2. add data from columns to combobox
    By justlearning123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2015, 09:36 PM
  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] objFolder to combobox with 2 columns
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2013, 01:13 PM
  5. Columns in combobox
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-16-2007, 06:34 AM
  6. [SOLVED] ComboBox with 2 columns
    By Stuart Grant in forum Excel General
    Replies: 4
    Last Post: 08-19-2006, 06:25 AM
  7. combobox with columns
    By JT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2005, 07:06 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