View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Determine if range has NO Blank Cells without looping through each

Maybe one of these approaches will help.

Sub test()
Dim rngTemp As Range

On Error Resume Next
Set rngTemp = Range("PreData").SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

If rngTemp Is Nothing Then
MsgBox "No Blanks"
Else: rngTemp.Select
End If

End Sub


Sub test2()

With Range("PreData")
If Application.CountA(Range("PreData")) = _
.Cells.Count Then
MsgBox "No Blanks"
Else: .SpecialCells(xlCellTypeBlanks).Select
End If
End With

End Sub



"Excelenator" wrote:


I have a range called "PreData" that is 12 rows and 6 columns and I want
to make sure the users fill in data in each of the cells. I am checking
the range in the Workbook_BeforeSave event and the code I am using to do
this is:


Code:
--------------------
Application.Goto Reference:="PreData"
Selection.SpecialCells(xlCellTypeBlanks).Select
--------------------


This works fine EXCEPT when there are no blanks. I know that the
Select is failing, I just don't know how to check it before actually
selecting it.

Any assistance will be appreciated!

Thanks!


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=567685