+ Reply to Thread
Results 1 to 4 of 4

Check multiple Cells and return a MsgBox Only if all are empty

  1. #1
    Registered User
    Join Date
    02-04-2019
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    41

    Check multiple Cells and return a MsgBox Only if all are empty

    Hi,

    I have a task, where there are various cells that used to register contact details. These are fixed in certain cells within the spreadsheet. Let's say they are A10, A12, A14, and A16. The registration sheet requires that at least one of the 4 contact detail field must be populated, but not necessarily all of them.
    I am looking to generate a MsgBox if all of these cells are Empty - but only all of them. If one of the 4 cells is populated, the macro would continue.

    I have tried the following code, but it of course checks each cell individually and not ignore the others if one is populated.

    Please Login or Register  to view this content.
    Is there a better way to do this so that if 1 of the 4 cells is populated, there is no MsgBox, but if none are populated, that I can have a MsgBox with a more generic message such as "Please populate at least one contact field" (just as a sample text).

    I am wondering if it is possible to Dim the 4 cells as a single range and then use the IsEmpty function?

    Thank you for any and all assistance, and guidance in advance.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Check multiple Cells and return a MsgBox Only if all are empty

    Perhaps a simpler approach: (Since you referenced A14 twice in your example, you may need to add the extra cell to the code)

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    02-04-2019
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Check multiple Cells and return a MsgBox Only if all are empty

    Thank you, that works perfectly.

    You are correct too, that A14 was referenced twice, one should have been A16 (I was simplifying the code from the actual code, for the task).
    I will try to adapt the code now to fit in with the logic I am attempting but it good to know this is a fall back in the event I cannot get it to work.

    Thanks again.
    Last edited by ChrisMP; 08-08-2019 at 11:11 AM.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Check multiple Cells and return a MsgBox Only if all are empty

    Glad I could help
    Thanks for the feedback and rep, and marking the 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] How to check multiple cells empty then call macro
    By sbv1986 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2018, 02:29 AM
  2. [SOLVED] need snippet to check two cells and paste into them if empty. if neither is empty, next i
    By Royzer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-09-2016, 07:17 PM
  3. Display none-empty cells in msgbox
    By Axmed.cm in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-26-2016, 01:19 AM
  4. Replies: 5
    Last Post: 03-10-2016, 02:24 PM
  5. [SOLVED] Check cell and return MsgBox if not a number
    By L plates in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-13-2015, 08:36 AM
  6. check multiple cells for values and return another value
    By amazzei in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-07-2014, 01:50 PM
  7. Empty cells not evaluating as empty - multiple check methods tried
    By rafadavidc in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-03-2014, 05:54 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