+ Reply to Thread
Results 1 to 6 of 6

Display the value in combo box in Excel VBA 2019

  1. #1
    Registered User
    Join Date
    10-10-2023
    Location
    India
    MS-Off Ver
    2019
    Posts
    8

    Display the value in combo box in Excel VBA 2019

    Hi all,

    I am fetching the rows from Database table. I want to populate one field value in Combo Box. Actually there are 6 different values say "Pending", "Open", "Close", "Work in Progress", etc. If the fetched record has the value "Open", I have to show it as "Open" in the combo box. At the same time, I have to allow the user to modify the options from "Open" to any value, say "Work In Progress", etc.

    Since I didn't know the no of records to be fetched from the database table, I only create the combo box only after the database operation. I hardcoded the 6 values.

    What I want is the combo box should display the value fetched from the table.

    How can I do that?

    This is my code:

    Please Login or Register  to view this content.
    thank you

    ComboBox_Error.jpg
    Last edited by EF_2023; 10-11-2023 at 06:06 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Display the value in combo box in Excel VBA 2019

    The value property is a reference to the position of the item in the list.
    So you could use the Match function to get that value, assuming the text to find is present in the list

    Please Login or Register  to view this content.
    or write a function to loop through the list items comparing text and then setting the value property. This way you can more easily handle no matching values.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    10-10-2023
    Location
    India
    MS-Off Ver
    2019
    Posts
    8

    Re: Display the value in combo box in Excel VBA 2019

    Thanks Andy for your response.

    I tried your code and also as per your suggestion to iterate the combo box items. But both gives error number as "1004".
    I am able to match the values with all the list of all combobox. No errors are there. but when I select the value on the combobox, displays error.

    Kindly see the picture.

    thank you

    EF_DropDownError.jpgEF_DropDownError1.jpgEF_DropDownError2.jpg

  4. #4
    Registered User
    Join Date
    10-10-2023
    Location
    India
    MS-Off Ver
    2019
    Posts
    8

    Re: Display the value in combo box in Excel VBA 2019

    my excel version is 2019 64 bit,
    OS : MS Windows 10 64 bit

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Display the value in combo box in Excel VBA 2019

    .Select should be .Value

  6. #6
    Registered User
    Join Date
    10-10-2023
    Location
    India
    MS-Off Ver
    2019
    Posts
    8

    Re: Display the value in combo box in Excel VBA 2019

    done. succeeded.

    Thank 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. help with combo box to display from list using search , on mac excel
    By HASSANPC in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-15-2021, 07:41 AM
  2. help with combo box to display from list using search , on mac excel
    By HASSANPC in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 01-14-2021, 07:42 PM
  3. [SOLVED] VBA (or function) to turn a date into a number i.e 12/31/2019 to 2019.12
    By lynnsong986 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-23-2019, 03:56 PM
  4. Replies: 2
    Last Post: 07-05-2019, 11:47 PM
  5. Reflect TBF vacancies over 2018-2019/2019-2020 budget year
    By jennah63 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2019, 07:32 PM
  6. [SOLVED] display relevant info in one combo box when selecting a value from another combo box
    By mailblade in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-31-2015, 09:28 AM
  7. Replies: 8
    Last Post: 12-26-2013, 02:23 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