+ Reply to Thread
Results 1 to 12 of 12

Multiple Conditional Message Boxes

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    69

    Multiple Conditional Message Boxes

    Hi,

    I am looking for a VBA with multiple message boxes based on following criteria:

    1) Check if specific cells are blank. If blank --> Message Box " Mandatory fields still blank - please fill cells"

    2) Check all other cells if there are blanks. If there are blanks--> Message Box "There are still empty cells - Proceed?"

    3) If both boxes have been passed, then Message Box "Control Check Complete"

    I found this VBA online which really helped - but i'm not sure how to add the other two conditions to make it work - any help please??? Thanks!!



    Sub FormatCheck()

    Dim CheckCell As Range

    For Each CheckCell In Sheets("FeederSheet").Range("E9,E15,E16,E18,E19").Cells
    If Len(Trim(CheckCell.Value)) = 0 Then
    CheckCell.Select
    MsgBox "Cell " & CheckCell.Address(0, 0) & " is a Mandatory Field. Click OK and fill the cell.", , "Missing Information"


    Exit Sub
    End If
    Next CheckCell

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Multiple Conditional Message Boxes

    Try something like this:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    07-17-2014
    Location
    Turkey
    MS-Off Ver
    2003
    Posts
    85

    Re: Multiple Conditional Message Boxes

    Hello. Your first answer;

    Please Login or Register  to view this content.

    second answer;

    Please Login or Register  to view this content.
    and last answer;

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-11-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Multiple Conditional Message Boxes

    Thanks both!

    I ended up using Olly's code which worked really well.

    Is there a line I could add to the code so that after stMessage = "There are still empty cells - Proceed?" and they click "Enter" , another message box showing "Control Check Complete" would pop up?

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Multiple Conditional Message Boxes

    Yup:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-11-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Multiple Conditional Message Boxes

    Wow that was simple to add.

    Thanks so much!

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Multiple Conditional Message Boxes

    Happy to help. Thanks for the feedback

  8. #8
    Registered User
    Join Date
    07-11-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Multiple Conditional Message Boxes

    Hi Olly,

    Sorry but is it possible to add two more criteria to the cases? So same code as you had above, but to check if:

    1) Cells ("E60:E64") are dates, and if not a Message Box will for example say: "Please enter valid date in cell E60".
    2) Final check for ranges E1:E60 if there are any #VALUE! or #REF! to prompt the user with a message box as well?

    Thanks!

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Multiple Conditional Message Boxes

    Okay, a bit more rework for these...

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-11-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Multiple Conditional Message Boxes

    Thanks so much Olly. For the code:

    For Each c In rngDates
    If Not IsDate(c.Value) Then
    iStatus = 2
    stMessage = stMessage & vbCr & " " & c.Address

    How could I change it so it is "If it is not a date" --> show message status 2. But if it is Blank, it will still move on to "Check Complete?"
    Basically check complete will only pop up if it is either: 1) A date or 2) blank.

    Sorry for all the questions - thanks so much for your help! I've been trying to modify it myself the whole day but couldn't figure it out

  11. #11
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Multiple Conditional Message Boxes

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    (Note: not tested, just posted, after wine!)

  12. #12
    Registered User
    Join Date
    07-11-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Multiple Conditional Message Boxes

    Wow you are amazing. Thank you so much for all of your help!

+ 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] Multiple Conditional (Dynamic?) Dropdown Boxes HELP!!!!!
    By Stephen_Malley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2014, 10:46 AM
  2. [SOLVED] Multiple message boxes for each locked cell in the same worksheet
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2013, 04:49 PM
  3. Message Boxes
    By mnoles01 in forum Excel General
    Replies: 1
    Last Post: 02-24-2009, 12:57 PM
  4. Message Boxes
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2006, 02:32 PM
  5. Displaying Multiple values with message boxes
    By Dani in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2006, 07:45 PM

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