+ Reply to Thread
Results 1 to 4 of 4

Update ComboBox after editing an item

  1. #1
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Update ComboBox after editing an item

    Hi,

    I hope you can help me spot the mistake in my code. I've been searching for a couple of days now but no luck.

    Background: In my project, I have two categories of variables, "decision factors" and "decision criterion". Each factor can have criteria. For this reason, I saved them in a two-dimensional array decisionFactors(factor, criterion) in which (factor,0) represents the original factor name. Some factors are given at the start, then the user can add more factors or criteria. Additionally, there's an integer array NumberOfCriteria(factor) that obviously counts the number of criteria that are assigned to each factor. This all works perfectly fine. The problem comes with editing them. For this, I created the following user form:
    temp.png
    in which the content of the lower ComboBox depends on the selected factor in the upper one. On edit, the user can then enter a new name for the selected factor/criterion which then overwrites the value in the decisionFactors array. I checked this step with a MsgBox and the respective element does have the new value. The ComboBoxes, however, do not adopt the new value although I wrote a refresh routine. There seems to be a mistake within this routine but I cannot find it.

    The code is as follows:

    In the user form posted above (extract):
    Please Login or Register  to view this content.
    In the user form in which the new name can be entered:
    Please Login or Register  to view this content.
    Refresh routine:
    Please Login or Register  to view this content.
    PS: I'm well aware that my coding is probably far from elegant but the goal for now is simply to get it running.

    I'd be very happy about any help, cheers!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Update ComboBox after editing an item

    Hello Menohavename,

    The chances of someone taking the time to recreate your project are slim to none. You will get a faster response by posting your workbook.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Update ComboBox after editing an item

    When you click the Edit button and update the decisionFactor array, you can also update the combobox at the same time. A combobox list is just another array. No need to Refresh the combobox.

    (Not tested)

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 02-21-2020 at 08:20 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Re: Update ComboBox after editing an item

    Quote Originally Posted by Leith Ross View Post
    The chances of someone taking the time to recreate your project are slim to none. You will get a faster response by posting your workbook.
    I thought, my mistake would be obvious to experienced VBA people only from looking at the code but I see the point. Will do so next time.

    Quote Originally Posted by AlphaFrog View Post
    Please Login or Register  to view this content.
    This works perfectly, thank you very much!

+ 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. Replies: 1
    Last Post: 01-18-2020, 12:44 AM
  2. Select Listbox Item by ComboBox Item
    By atadaliran in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-10-2017, 04:04 PM
  3. [SOLVED] update listbox item only updates first item
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-24-2014, 04:16 PM
  4. selecting an item in combobox, the item does not get selected
    By AVM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2014, 05:14 AM
  5. [SOLVED] Error 2042 using Application.Match to add item and update combobox list
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2013, 07:55 AM
  6. Update Rows in Database based on Combobox selected item on Userform. Problem .
    By jmarriott in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-09-2013, 01:08 PM
  7. Combobox: How to determine the location of the selected item if combobox has rowsource
    By ahsanzafar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2012, 03:24 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