View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Duncan[_5_] Duncan[_5_] is offline
external usenet poster
 
Posts: 290
Default counting records

or......


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


For Each cell In Worksheets("sheet1").Range("A1:A500")
If cell.Value < isblank = True Then
count = count + 1
End If
Next cell
countrecords = count
MsgBox count
End Function






Norman Jones wrote:

Hi Panagiotis,

Try:

'=============
Public Function countrecords() As Integer
Dim count As Integer
Dim cell As Range
count = 0

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


---
Regards,
Norman



"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