View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default counting records

Panagiotis,
The keyword "Is" is used with Objects.
Dim WB As Workbook
On Error Resume Next
Set WB=Workbooks.Open(PathToFile)
If Not WB Is Nothing Then.....

But cell.value is not an object.
Depending what you are test for:
cell.value<0 or Not (cell.value=0)
cell.value<""
cell.value<Empty

NickHK

"Panagiotis Marantos" wrote
in message ...
can somebody provide me with an answer as to why the following function
returns an error on the if line?

the error message is "object required"

Function countrecords() as integer
Dim count As Integer
count = 0

For Each cell In Worksheets("Saved Records").Range("A1:A500")
If cell.Value Is Not Null Then
count = count + 1
End If
Next cell
countrecords = count
End Function