Okay, I see what you are doing... you are using the Abs value function to
filter out the negative values (forcing a False for them). Ok, as long as
the OP's understanding of "whole numbers" is the same as yours, your
statement is fine.
My understanding of the definition of "whole numbers" is "the set of
positive integers, including zero". If the OP meant "integer number",
then I agree to remove the Abs wrapper in the test, as you suggest.
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
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.