+ Reply to Thread
Results 1 to 13 of 13

Error message when inputbox entry does not match UF listbox item

  1. #1
    Registered User
    Join Date
    07-01-2015
    Location
    Antwerp
    MS-Off Ver
    2019
    Posts
    71

    Error message when inputbox entry does not match UF listbox item

    Dear Excel enthusiasts,

    I have a search button that selects a matching item (e-mail address) in a userform listbox. The search button opens an inputbox in which to type your entry.
    The entry has to meet certain formatting criteria mentioned in the code below.

    I would like to have an error message "ENTRY NOT FOUND" if the inputbox entry does not match any of the listed e-mail addresses. However, my code returns this message also/even when the input entry DOES match a listbox item. Anyone knows the reason why this happens and could alter the code accordingly?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Error message when inputbox entry does not match UF listbox item

    not easy to say without the workbook - see big yellow banner - upload it with a few lines of de-sensitised data.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    07-01-2015
    Location
    Antwerp
    MS-Off Ver
    2019
    Posts
    71

    Re: Error message when inputbox entry does not match UF listbox item

    Hi Torachan,
    I uploaded the workbook with desensitised data. I hope it makes the issue more clear. Testsheet with UF code.xlsm

  4. #4
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Error message when inputbox entry does not match UF listbox item

    .
    Hello.
    Try with:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-01-2015
    Location
    Antwerp
    MS-Off Ver
    2019
    Posts
    71

    Re: Error message when inputbox entry does not match UF listbox item

    Hi Beyond Excel, thanks for your swift answer. I am not really familiar with arrays but your mysterious code seems to do the job.

    Do you know how to adapt your code when the first three or more initial letters of the entered mail address should give a matching list item result as well?

  6. #6
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Error message when inputbox entry does not match UF listbox item

    Hello.
    I find that what I am attaching is quite intuitive to use.

    >With each letter you type in the comboBox, a database lookup will be performed.
    >The Add and Remove buttons work "just like you imagine."
    >When you type a new email address in the comboBox and press any Add button, the address will be added to the corresponding listBox as well as the general list.
    >And the upper Remove button removes the address selected in the comboBox from the general list.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-01-2015
    Location
    Antwerp
    MS-Off Ver
    2019
    Posts
    71

    Re: Error message when inputbox entry does not match UF listbox item

    Hi Beyond Excel. Your combobox solution is very intuitive indeed. I guess that if I want to add duplicate entry or no blank entry restrictions for adding new e-mail addresses in the general list, I include those criteria in the Private Sub Add(lb) coding, right?
    Or will "add item"-restrictions also affect the search function with the same restrictions (which is to avoid)?

  8. #8
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Error message when inputbox entry does not match UF listbox item

    You can fix the duplicate entry by replacing what I passed you with this variant:

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Error message when inputbox entry does not match UF listbox item

    Although it may be cheaper to do it like this:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-01-2015
    Location
    Antwerp
    MS-Off Ver
    2019
    Posts
    71

    Re: Error message when inputbox entry does not match UF listbox item

    Wow, you are a genius man. I only added the criterium of no commas in a new entry but it still adds entries with commas. Any idea why?

    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Error message when inputbox entry does not match UF listbox item

    How about you consider replacing commas with periods automatically?...

    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    07-01-2015
    Location
    Antwerp
    MS-Off Ver
    2019
    Posts
    71

    Re: Error message when inputbox entry does not match UF listbox item

    That works fine.
    My last question: How can I force a new entry to avoid any spaces and to end on "@x.y.z"?
    And have a message box pop up "there should be at least one sender address" when there are no addresses in the sender listbox?

  13. #13
    Registered User
    Join Date
    07-01-2015
    Location
    Antwerp
    MS-Off Ver
    2019
    Posts
    71

    Re: Error message when inputbox entry does not match UF listbox item

    Hi,
    I added the following code to transfer the listbox entries to a named range table "SList" (with the sender e-mail addresses) on a worksheet, but it does not seem to work 100%. Anyone has an idea on how to improve the code?

    Please Login or Register  to view this content.

+ 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. vba excel - last listbox item transfer erasing all listbox items except last item
    By terriertrip in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-06-2017, 03:48 PM
  2. runtime error 70 when try to add item to listbox
    By shiva_raj in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-03-2017, 05:42 AM
  3. Error 2015 message with InputBox
    By joe_sans in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 06-29-2016, 07:47 AM
  4. Run Time Error when Deleting last Item in ListBox
    By gunsmith01 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-11-2014, 03:05 AM
  5. remove item error message
    By spitta in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-25-2014, 04:09 PM
  6. [SOLVED] Inputbox error message. Formula you typed contains an error.
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-09-2013, 02:25 PM
  7. [SOLVED] Error handling on InputBox entry when nothing is entered
    By Kungfauxn00b in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2011, 04:45 AM

Tags for this Thread

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