+ Reply to Thread
Results 1 to 5 of 5

Updating a combobox selection

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    35

    Updating a combobox selection

    Hi there,

    I have a userform used to input data. I contains textboxes and comboboxes
    and a command button that is clicked on to record the data onto a worksheet.

    What I am looking for is a combobox that is linked to a list of clients (column A of worksheet "Clients").

    I would like the user to click on the combobox and select a client name. If the
    client is new then I would like the user to be able to type in the new name and,
    then have that name available in the "Clients" names that appear the next time
    the user clients on the combobox.

    I have it almost working, but not quite.

    I have a defined name on the "Clients" worksheet as follows:

    Please Login or Register  to view this content.
    I have the same code as the RowSource for the combobox

    What happens now is that the first time the combobox is selected, all the client names
    appear in the combobox, but if a new name is added, the combobox doesn't grow in size.
    Instead the last entry is removed.

    The command button code is below.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Updating a combobox selection

    It would help us a lot if you attach your workbook with sample data and macros.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Updating a combobox selection

    Thanks for responding Pierre,

    I have created a simplified workbook with some generic data. A little info on what I am trying to so:

    We have workbook clients with 9 columns of information. I am creating a userform for us to use to fill in the information. The form I created has text and combo boxes.
    I have simplified the workbook attached, but the idea is the same. The workbook has 3 sheets "Log", "Enter", and "Clients". The data is filled in with the text or combo box.
    When the "Enter Client" command button is clicked, the data is copied from the "Enter" sheet to the next available row on the "Log" sheet. The "Log" sheet is used as a log of
    all the entries made (some fields may repeat, but not all of them).

    Then the client name is copied from the "Enter" sheet to the next available cell of column "A" on the "Clients" sheet. The names are then sorted alphabetically and duplicate
    entries are deleted. I have a defined name range called "ListClients" that is used as a source for the combo box. This is where the error happens.

    At this point, everything works. The 'Enter Client' does all it's supposed to. The problem is the named range "ListClients" doesn't update properly after the first client
    'new' client name is added to the list. If the Client name that is added already exists (is already part of the "ListClients" nothing needs to happen, but if the name is a new one
    (for this example, Frank is not a client name and would be 'new'. When that is entered, it gets added to the "Log", added to the "Client Names" and the list is sorted, but then next
    time the form is used, the last name in the "ListClients" named range does not appear (in this case, "William').

    That's the problem I am having. Sorry for being so long winded. I hope this makes sense. If there is an easier way of doing what I am attempting, I would appreciate hearing about it.

    Thanks in advance.

    Frank
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-15-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Updating a combobox selection

    My apologies.

    Please ignore the previous attachment.

    USE THIS INSTEAD.
    Attached Files Attached Files

  5. #5
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Updating a combobox selection

    Here is what I found. It makes the combobox working now.
    First, your second sort lines of code had Header = xlYes but it should be xlNo because you are not selectingthe titles' row.
    Second, I added a line defining again the row source of the combobox so it is updated to its new dimension. I remarked that if you enter 3 new names, you were loosing the last 3 clients name in the combobox. Probably because it was not updated unless you close the form and reload it again.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-15-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Updating a combobox selection

    Thanks...just tried it out and yes it works perfectly...thanks for your help...

+ 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. Userform Combobox to populate based on selection in another combobox
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2014, 03:34 PM
  2. [SOLVED] Filter Combobox base on selection from previous combobox
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2013, 07:25 PM
  3. [SOLVED] Make combobox list options dependant on selection in another combobox within a userform
    By Vladimir_Dobvchenko in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-23-2013, 05:30 AM
  4. [SOLVED] fill combobox selection based on a selection from the first combobox
    By Monza in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-14-2013, 07:34 PM
  5. [SOLVED] code for updating rows based on a userform combobox selection
    By raluk_ro22 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2013, 11:09 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