+ Reply to Thread
Results 1 to 4 of 4

check if any cell in a dynamic range is empty

Hybrid View

  1. #1
    Registered User
    Join Date
    08-20-2007
    Posts
    60

    check if any cell in a dynamic range is empty

    I need to make sure all the inputs are entered before running a macro. In order to do that, I would like to make sure none of the cells in the range (which is dynamic and I know the range) is empty. How to do that?

    Thanks in advance, Anil

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Here's what I would do. Assuming your dynamic range is named "named"
    =IF(ROWS(Named)>COUNTA(Named),"Blanks","No Blanks")
    It counts the number of rows against the number of entries. Does that work for you?

    ChemistB

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello akabraha,

    Here is another way. With this method you can identify the cells that are blank (empty). It will display a message box listing the cells that are blank.
    Sub CheckForBlanks(Rng As Range)
    
      Dim Blanks As Range
      
        On Error Resume Next
          Set Blanks = Rng.SpecialCells(xlCellTypeBlanks)
        
        If Not Blanks Is Nothing Then
          For Each Addx In Split(Blanks.Address, ",")
            Msg = Msg & Addx & vbLf
          Next Addx
            If Msg <> "" Then
              MsgBox "The Following cells are empty:" & vbLf & Msg
            End If
        End If
        
    End Sub
    Example
    Sub Test()
     'Will display a list of empty cells in the range, if there are any
      CheckForBlanks Range("A2:F465")
      
    End Sub
    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    08-20-2007
    Posts
    60

    Thanks

    Thank you ChemistB and Leith Ross (you are the Excel Guru). CountA worked for me.

    Thanks again, Anil

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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