Validation for blank cells

crims0n

New Member
Joined
Aug 18, 2011
Messages
12
Hi,

Here is a code for checking blank cells in 1 column. Let's say we have 3 column populated with values. On the last row, column 1 is empty while the other are not. when i run this code it returns No Blanks. What do I need to add so it can also check the last row which is empty.

* I ommitted the part where it gives the number of blank cells since i'am currently working on the last blank row.

Code:
  Dim Holder As Range
  Dim Answer As Integer
  Dim blanks
 
  Set Holder = Range("A2:A" & Range("A65536").End(xlUp).Row)
  Answer = 0
 
' Count each blank cell.
       For Each x In Holder
           If IsEmpty(x.Value) Then Answer = Answer + 1
       Next x
 
   blanks = Holder.Address(False, False)
 
   If Answer > 0 Then
    MsgBox "There are blanks in " & blanks & ""   
   Else
    MsgBox "There are No blanks"
   End If

Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
How about this to check all three columns for blank cells?
Rich (BB code):
Sub TestForBlanks()
Dim LR As Long
Dim RNG As Range

LR = Cells.Find("*", Cells(Rows.Count, Columns.Count), _
    SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
On Error Resume Next
Set RNG = Range("A2:C" & LR).SpecialCells(xlCellTypeBlanks)

If Not RNG Is Nothing Then
    MsgBox "There are " & RNG.Cells.Count & " blank cells"
Else
    MsgBox "There are no blank cells"
End If

End Sub


You can change that red C to A to really just check column A.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,258
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top