+ Reply to Thread
Results 1 to 5 of 5

MsgBox on Error - code needed

  1. #1
    Registered User
    Join Date
    04-28-2021
    Location
    Clanfield
    MS-Off Ver
    Microsoft 365
    Posts
    52

    MsgBox on Error - code needed

    hi,

    I am using Combobox on my form to allow Users to select available items from the General Stock List. It works well but when someone is typing code name and the code is not there there is a vlookup error message. How can i amend the code so when there is an error a MsgBox is displayed to say "The item you are looking for is not on the list" and the USerForm is NOT Closing. My current code for the ComboBox is as below:
    HTML Code: 

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: MsgBox on Error - code needed

    Just don't let them type, only items in the combobox, you can set that in the properties
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    04-28-2021
    Location
    Clanfield
    MS-Off Ver
    Microsoft 365
    Posts
    52
    Quote Originally Posted by Keebellah View Post
    Just don't let them type, only items in the combobox, you can set that in the properties
    Well, I do want to let them type as the list in ComboBox is long ( in alphabetical order) as by typing first few characters allows them to find relevant code quicker

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: MsgBox on Error - code needed

    The you'll have to use the IFERROR() integrated in the macro
    Will need a sample of your file to work something out
    It's past midnight here so I'm off to bed.
    I quite often use a textbox where the user can start typing filters a Listbox as they type (instead of a Combobox)

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: MsgBox on Error - code needed

    Could you attach a file with non-sensitive data ?

+ 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] Msgbox Code - VBA 2016 - Runtime Error
    By RAFA_NADAL in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2018, 11:09 PM
  2. Help Needed There are some error in my code
    By dukesfather in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2016, 02:26 AM
  3. Prevent #DIV/0 error Code Needed
    By JJFletcher in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-07-2015, 04:04 PM
  4. Edit code to loop error msgbox and inputbox until valid date is entered by user.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-11-2012, 10:07 PM
  5. Error in code to skip cells between entry fields - help needed!
    By rache66 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2010, 07:57 AM
  6. More help needed re form & msgbox
    By Pam Field in forum Excel General
    Replies: 3
    Last Post: 07-22-2006, 08:10 AM
  7. [SOLVED] MsgBox Code Error
    By MBlake in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-02-2005, 07:06 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