How to check that all cells in range are not empty using VBA?

Anonymous
2024-02-22T20:50:34+00:00

Hi,

I have a spreadsheet similar to what is shown below, and I need to use VBA to ensure that none of the data entry cells (blue cells on form) are empty when I go to print the form. I know I can check each cell using If Range(Cell)="" and Range(Cell2)=""... but I would like to know if there is a better way: Maybe check the whole group of cells by naming the entire group of blue cells; Checking entire ranges; Looping through all cell options; Or any another better option.

Thanks, SP

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. HansV 462.4K Reputation points MVP Volunteer Moderator
    2024-02-22T21:40:52+00:00

    You could use

    If Application.CountA(Range("A2:H2,B3:I4,B6:V7,B9:V9,B11:V11,B13:V13,B15:V15")) = 0 Then
    
    1 person found this answer helpful.
    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. OssieMac 47,981 Reputation points Volunteer Moderator
    2024-02-22T21:36:54+00:00

    You have two different shades of blue. Which group are you referring to or do you want to check both groups.

    0 comments No comments
  2. Anonymous
    2024-02-22T21:52:08+00:00

    Sorry for the confusion. Just the empty light blue cells. Thanks!

    0 comments No comments
  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. HansV 462.4K Reputation points MVP Volunteer Moderator
    2024-02-23T14:26:29+00:00

    Does any of those cells contain a formula that returns "", so that it looks empty?

    0 comments No comments