Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default How to confirm a cell entry is a whole number

Any suggestions on how to confirm that the value in a cell is a whole
number?

Bob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default How to confirm a cell entry is a whole number

Robert Flanagan wrote:
Any suggestions on how to confirm that the value in a cell is a whole
number?

Bob



Def IsWholeNumber as Boolean
IsWholeNumber = MyValue = Abs(Int(MyValue))
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to confirm a cell entry is a whole number

I'm pretty sure you don't want the Abs function in there (at least not how
you used it). What is wrong with just this....

IsWholeNumber = MyValue = Int(MyValue)

--
Rick (MVP - Excel)


"smartin" wrote in message
...
Robert Flanagan wrote:
Any suggestions on how to confirm that the value in a cell is a whole
number?

Bob


Def IsWholeNumber as Boolean
IsWholeNumber = MyValue = Abs(Int(MyValue))


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default How to confirm a cell entry is a whole number

Rick Rothstein wrote:
I'm pretty sure you don't want the Abs function in there (at least not
how you used it). What is wrong with just this....

IsWholeNumber = MyValue = Int(MyValue)


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.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to confirm a cell entry is a whole number

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.

--
Rick (MVP - Excel)


"smartin" wrote in message
...
Rick Rothstein wrote:
I'm pretty sure you don't want the Abs function in there (at least not
how you used it). What is wrong with just this....

IsWholeNumber = MyValue = Int(MyValue)


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.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default How to confirm a cell entry is a whole number

smartin wrote:
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.


The definition is ambiguous:
http://en.wikipedia.org/wiki/Whole_number

Phil Hibbs.
  #7   Report Post  
Posted to microsoft.public.excel.programming
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
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default How to confirm a cell entry is a whole number

Phil Hibbs wrote:
smartin wrote:
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.


The definition is ambiguous:
http://en.wikipedia.org/wiki/Whole_number

Phil Hibbs.


I find it unintuitive that a negative integer would be considered
"whole", but your point is well taken. I should not assume "whole
number" has a specific meaning in common parlance.

FWIW the definition I used was the one imposed upon me 30-odd years ago.
We were rigorously tested on our ability to place a number in the
correct domain(s) of counting numbers, whole numbers, integers, rational
numbers, irrational numbers and complex numbers. Visions of Venn
diagrams are flooding back to me.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making a specific row number active from a cell entry Bilbo Baggs Excel Discussion (Misc queries) 15 May 24th 10 06:29 PM
Formula to confirm entry in Col "C" is valid for data in Col "A" VAPCMD Excel Discussion (Misc queries) 2 January 2nd 09 07:58 PM
How do I make a cell with vertical lines for number entry? Russ[_5_] Excel Discussion (Misc queries) 4 February 21st 08 03:08 PM
script to increase last number in cell entry for hyperlink kim Excel Programming 1 January 3rd 08 12:01 PM
Confirm target cell is equal Pat Excel Discussion (Misc queries) 2 December 8th 04 09:35 PM


All times are GMT +1. The time now is 12:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"