+ Reply to Thread
Results 1 to 14 of 14

Data from Listbox Column to Combobox

  1. #1
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Data from Listbox Column to Combobox

    I have a userform (frmClientInvoices) with a three column listbox (lstClientInv).
    After making a row selection in the listbox I wish to pass the item in the third column of the listbox into a userform (frmInvoiceDetails) with combobox (cmbInvNo).
    The frmInvoiceDetails is already open.
    The command button code on frmClientInvoices I have so far is (but it’s not working):

    Please Login or Register  to view this content.
    How can I alter the code to get it working?
    Thanks Sandy

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data from Listbox Column to Combobox

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Data from Listbox Column to Combobox

    Tried your code but got an error "Invalid or Unqualified reference" with ".ListCount" highlighted!!

  4. #4
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Data from Listbox Column to Combobox

    I have corrected a spelling mistake.

    The first line of the code below works in that it puts the first column value of the list box into the combobox without any errors.
    If I change it to the second line (without the first line) it does not work! It does not work with or without ".Value" at the end.


    Please Login or Register  to view this content.

  5. #5
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Data from Listbox Column to Combobox

    List columns are zero based & you need the index of your choice not the count.
    torachan.
    try
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Data from Listbox Column to Combobox

    I am still getting the same error message - "Invalid or Unqualified reference" with ".ListCount" highlighted.

  7. #7
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Data from Listbox Column to Combobox

    why are you using .ListCount you need to know the index

  8. #8
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Data from Listbox Column to Combobox

    Attached is my current spreadsheet.
    Click on the commandbutton to open frmInvoiceDetails.
    Then click in "Client" textbox to open frmClientInvoices, and make a selection from the list.
    Then click "Enter", which should put selection (offset by one) into combobox.
    I.e. By selecting "Aaron Gordine" the value in compbobox should be "INV-0084".

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Data from Listbox Column to Combobox

    Tools > References remove tick from the missing box.
    Capture.JPG

  10. #10
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Data from Listbox Column to Combobox

    Sorry, a little bit slow of the mark today - put it down to my advanced years - forgotten more than I have learned.
    Working across two forms you have to be able to carry the variables - declare globals in a module - best to 'google' and do some reading.
    I can not see why you are using two forms - make it easy on yourself - use a single form - declare your variables at the head of your code - start with "Option Explicit".
    Then run debug as you develop each stage of your code to eliminate omissions.

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Data from Listbox Column to Combobox

    To avoid the unqualified property call, use:

    Please Login or Register  to view this content.
    Rory

  12. #12
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Data from Listbox Column to Combobox

    Finally got it sorted by using the code below:

    Please Login or Register  to view this content.
    Thanks for all the input, it all helps in the understanding of VBA.
    Cheers Sandy

  13. #13
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Data from Listbox Column to Combobox

    alternative compact single form approach
    Last edited by torachan; 10-21-2020 at 10:29 AM.

  14. #14
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Data from Listbox Column to Combobox

    Thanks torachan. I was wondering how to develop a single form. I will now use your file to continue developing the project I'm on.
    I loved your "advanced years" comment. I'm the same category!
    Cheers Sandy

+ 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. Transfer Textbox/Combobox Values to a Multiple Column Listbox Error381
    By el-paso in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2020, 06:17 PM
  2. Replies: 0
    Last Post: 05-06-2019, 03:36 PM
  3. [SOLVED] ComboBox to filter Listbox Data
    By TommyMurphy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-02-2019, 12:25 PM
  4. [SOLVED] ComboBox to populate Listbox and 2nd Combobox based on 1st combobox dropdown choice
    By bbqqsmokeman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2017, 08:21 PM
  5. Problem with filtering data in a listbox using a combobox value
    By lboromark in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 07-27-2015, 06:47 AM
  6. Replies: 2
    Last Post: 12-07-2012, 02:10 AM
  7. [SOLVED] Multi Column Listbox change based on a selection from a combobox
    By AttalaEA in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-21-2012, 06:00 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