View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Bernd P Bernd P is offline
external usenet poster
 
Posts: 806
Default How to confirm a cell entry is a whole number

Hello Bob,

Function IsWhole(r As Range) As Boolean
'TRUE if all values in range are whole numbers, FALSE if not.
Dim v, b As Boolean
For Each v In r
If v.Value < CLng(v.Value) Then
IsWhole = False
Exit Function
End If
Next v
IsWhole = True
End Function

Here a whole number is a valid LONG number.
Change Clng to Int if you want to accept numbers 1E15 as well.

Regards,
Bernd