+ Reply to Thread
Results 1 to 3 of 3

Error 2042 using Application.Match to add item and update combobox list

  1. #1
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Error 2042 using Application.Match to add item and update combobox list

    Hi all

    I have the following code that adds a new item to a combobox list

    Please Login or Register  to view this content.
    The list of Garage names is in sheet "Module Data". A new Garage name can be inserted in a Textbox "NewGarage".

    The code successfully inserts a new name in alphabetical order.

    However, if the new name is above the first alphabetically listed name, it gives an error (2042). The workround that I did was to put a dummy name "AAAAAAA" first in the list and the code works.

    Can anyone suggest why this is so and what can be changed in the code to add the new name at the top?

    Thanks

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Error 2042 using Application.Match to add item and update combobox list

    Match type 1 finds the largest value that is less than the search value. so if your search value is B and you are looking in data with a lowest value C it will not find any values less than the search value and will return an error. You just need some error handling for this:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: Error 2042 using Application.Match to add item and update combobox list

    Thanks yudlugar. Your suggestion did the trick. It works now.

    Cheers

+ 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. [SOLVED] Application.Match returns Error 2042 whene text absolutely does exist?
    By Rhudi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2013, 04:21 PM
  2. Sporadic error when adding item to ComboBox
    By Gabor in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-14-2013, 01:57 PM
  3. 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
  4. Error 2042 with Application.Match
    By mgurren in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2013, 02:15 AM
  5. [SOLVED] Error 2042 with application.vlookup for date
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2013, 03:57 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