+ Reply to Thread
Results 1 to 9 of 9

Validation Error loop

  1. #1
    Registered User
    Join Date
    10-15-2022
    Location
    Cornwall, England
    MS-Off Ver
    Office 365
    Posts
    10

    Validation Error loop

    This is so silly as there MUST be a simple answer but I'm damned if I can find it. I want to put in a simple inbox asking the user to put in a date (for an invoice). If they fail to enter a date in a recognisable date form, I want a MsgBox to display the error ("Invalid date") and then loop back to the original inbox requesting a date. I dob't know wjy I'm struggling with this (I'm an amateur at VBA) but I cannot find an answer on the Internet. Any help, much appreciated!

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Validation Error loop

    Hi Cleepq,

    Here's one way:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

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

    Re: Validation Error loop

    Greetings to all.
    Another way to do it is as follows:

    Please Login or Register  to view this content.
    Last edited by beyond Excel; 11-18-2022 at 11:08 PM.

  4. #4
    Registered User
    Join Date
    10-15-2022
    Location
    Cornwall, England
    MS-Off Ver
    Office 365
    Posts
    10

    Re: Validation Error loop

    Thanks, Robert - very kind of you. It works well except it doesn't pick up an invalid date such as 30/02/2022. Nevertheless your help is very much appreciated - and I have learnt a lot from studying the structure!

  5. #5
    Registered User
    Join Date
    10-15-2022
    Location
    Cornwall, England
    MS-Off Ver
    Office 365
    Posts
    10

    Re: Validation Error loop

    Perfect! Thank you!

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

    Re: Validation Error loop

    Quote Originally Posted by Cleepq View Post
    Perfect! Thank you!
    Don't forget, Cleepq, to add reputation * (bottom left of each message) on the posts that helped you solve your problem.

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Validation Error loop

    Hi Cleepq,

    Though I see beyond Excel has provided a nifty solution and for anyone going through this thread, if you replace this line of code in my macro...

    Please Login or Register  to view this content.
    ...with this it should do the job:

    Please Login or Register  to view this content.
    Thanks,

    Robert

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

    Re: Validation Error loop

    Oh !!!... Thank you so much for that "nifty solution" thing, Trebor76.

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Validation Error loop

    Oh !!!... Thank you so much for that "nifty solution" thing, Trebor76.
    You're welcome. Credit where credit's due I say.

+ 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 with a loop across columns with an inside loop down rows
    By kds14589 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-27-2022, 09:28 AM
  2. [SOLVED] Excel VBA - Loop through recordsets ADODB with For Loop Error - Help
    By ironfelix717 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-27-2018, 08:44 AM
  3. [SOLVED] reversed validation: how to get an error message if the item IS on the validation list?
    By jokkebal in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-29-2017, 09:29 AM
  4. [SOLVED] Go to next loop iteration if current loop has error
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-03-2016, 09:54 PM
  5. HOW TO: Pause loop, fix error on a popup UserForm, continue loop
    By AndyMachin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-19-2014, 04:37 PM
  6. [SOLVED] Using Dependant Validation. Show error or blank if Inital Validation Changes
    By marsham in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-20-2013, 04:24 PM
  7. Blank Validation Loop within Loop
    By vbhal in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-18-2011, 10:54 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