+ Reply to Thread
Results 1 to 8 of 8

error checking a userform dropdown box

  1. #1
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    error checking a userform dropdown box

    hi guys, I have a userform with some dropdown boxes for a user to choose a Month no, which when chosen data is copied from one sheet to another which all works fine, I was wondering if anyone had any code that I could use, so if a user chose say month 10, but data in the records sheet does not exist for that month then a message box appears asking the user to choose a different month number and the code is stopped, Month numbers are stored in column Z on the records sheet.

    many thank

    scouse13

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: error checking a userform dropdown box

    Not sure of your setup as no sample file attached...This will give you an idea
    Please Login or Register  to view this content.
    Last edited by Sintek; 04-22-2020 at 06:36 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Re: error checking a userform dropdown box

    Thanks for the reply sintek, below is the code from the command button that copies data based on the combobox selection (the combobox is pre-populated from a list on a different sheet - there is no code behind the combobox), if I can try to explain again, the user would pick a number from the combobox and then press the command button to copy the data, what I need to happen is when the selection is made in the combobox, code runs to see if that number exits in the records sheet, is so the user presses the command button if it does not exist then a message box appears asking them to make another selection, hope this makes it a bit clearer
    scouse13
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: error checking a userform dropdown box

    And why have you posted the CommandButton code?

    what I need to happen is when the selection is made in the combobox, code runs to see if that number exits in the records sheet, is so the user presses the command button if it does not exist then a message box appears asking them to make another selection, hope this makes it a bit clearer
    This was clear from the beginning...Post 2 code solves that...Just incorporate it into your ComboBox that the user makes selection from...
    Please Login or Register  to view this content.
    Change Red 1 to your ComboBox No...
    Change Green Z to the column you want to search...
    If you do not know how to incorporate then I suggest you upload a sample file...
    Last edited by Sintek; 04-22-2020 at 10:11 AM.

  5. #5
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Re: error checking a userform dropdown box

    hi sintek, tried that code again in the combobox, it does not matter what number is selected the message box appears, in the records sheet I have records that in column z are showing as 1 and 5, , so selecting 1 or 5 in the combobox should just run the code, and if I selected 3 this should show the message box.

    ie the code should check the records sheet column z and confirm the numbers are in there.

    scouse13

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: error checking a userform dropdown box

    Works for me...I cannot test scouse13 as I do not have a sample file of your setup...
    In future always supply a sample...That way your query can be solved correctly...3rd time I've mentioned sample file...

    EDIT...Here's another method
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Sintek; 04-22-2020 at 12:22 PM.

  7. #7
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Re: error checking a userform dropdown box

    Hi sintek thanks for your help, I played around with your file / code you sent, and have got it working the way I need,
    have re-attached the file so if anyone else has the same same problem the answer is available.
    thanks again for your help.
    scouse13
    Attached Files Attached Files

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: error checking a userform dropdown box

    Glad you got it sorted...Tx for rep +
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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] Error Checking Multiple Checkboxes in a Userform
    By mo4391 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2016, 12:01 PM
  2. [SOLVED] Independent Dropdown list in Userform Comobobox cause Find Next/Previous Error
    By Faridwahidi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2015, 11:11 PM
  3. Error Checking with Range cell in Userform. Thank you!
    By florayaoyao in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2014, 07:23 PM
  4. [SOLVED] Error checking routine - check range values on various worksheets and report if error
    By TheRobsterUK in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-29-2014, 06:36 AM
  5. Replies: 2
    Last Post: 02-18-2013, 10:17 AM
  6. Error 1004 - hitting a key in a dropdown list of a userform
    By ggabi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2012, 06:19 AM
  7. Checking a userForm that has not been initialized
    By Arne Hegefors in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-02-2006, 09:50 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