Error when entering a number in combobox that doesn't exist

  • I have a column A, containing 4 digits numbers all starting with 1, 2, 3, 4 or 5.

    The starting number represents departments. So there are 5 departments.

    Every department contains different items. So the numbers go for example from 1001 to 1067, from 2001 to 2134, and so on. The item numbers are stored in column A, the items in column B and the name of the department in column C.

    I have a combobox on a userform. This userform is filled with all the Numbers from column A with this code:

    cboZoekProduct.list = Range("tabel3515").Value

    The user can pick a number from the combobox, but he can also enter a number manually.

    After picking a number from the combobox, a listbox is filled with the three columns.

    When the user enter a number that doesn't exists, i get an error.

    When the user enters a number starting with a "1" that is higher than the highest number in the column starting with a "1", I get an error.

    This is my code that isn't working:

    What is going wrong? Any help would be much appreciated!

    Also the code is put in the afterupdate event, I would like it better in the change event, but I get an error after entering the first digit in the combobox.

    Thx in advance

  • Hi AL,

    If you are still interested in a solution for this please upload an example workbook with the code not working. It is possible to recreate your sheet and test it, but it would be easier if you had it ready to go.



Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!