Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hiya there,
Can anyone tell me how I can test a variable to see if it is a whole number? I want to write something like: do until variable = integer I am just playing around trying to write something that will generate a list of prime numbers... I know how I could test a given list to show True if it is a prime but I want to create a list of just prime numbers. Can anyone help? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Pablo,
Can anyone tell me how I can test a variable to see if it is a whole number? Try something like: '=============== Public Sub Test() Dim rng As Range Dim rCell As Range Set rng = Range("A1:A10") For Each rCell In rng.Cells With rCell If IsNumeric(.Value) Then If .Value = 1 Then If .Value = Int(.Value) Then MsgBox .Value & vbTab & "Integer!" Else MsgBox .Value & vbTab & "not an integer!" End If End If End If End With Next End Sub '<<=============== --- Regards, Norman "pablo bellissimo" wrote in message ... Hiya there, Can anyone tell me how I can test a variable to see if it is a whole number? I want to write something like: do until variable = integer I am just playing around trying to write something that will generate a list of prime numbers... I know how I could test a given list to show True if it is a prime but I want to create a list of just prime numbers. Can anyone help? Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
IF yourvariable MOD 1 = 0 THEN
Regards, Stefi "pablo bellissimo" wrote: Hiya there, Can anyone tell me how I can test a variable to see if it is a whole number? I want to write something like: do until variable = integer I am just playing around trying to write something that will generate a list of prime numbers... I know how I could test a given list to show True if it is a prime but I want to create a list of just prime numbers. Can anyone help? Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Steffi,
IF yourvariable MOD 1 = 0 THEN From the imediate window: ? 1.25 Mod 1 0 ? o Mod 1 0 ..--- Regards, Norman "Stefi" wrote in message ... IF yourvariable MOD 1 = 0 THEN Regards, Stefi "pablo bellissimo" wrote: Hiya there, Can anyone tell me how I can test a variable to see if it is a whole number? I want to write something like: do until variable = integer I am just playing around trying to write something that will generate a list of prime numbers... I know how I could test a given list to show True if it is a prime but I want to create a list of just prime numbers. Can anyone help? Thanks |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() From the imediate window: From the immediate window: --- Regards, Norman "Norman Jones" wrote in message ... Hi Steffi, IF yourvariable MOD 1 = 0 THEN From the imediate window: ? 1.25 Mod 1 0 ? o Mod 1 0 .--- Regards, Norman |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Norman,
Sorry, of course you are right. I mistook remainder for fractional part and didn't test my answer. The right answer IF yourvariable - INT(yourvariable) = 0 THEN I appreciate very much your being particular about spelling. Regards, Stefi "Norman Jones" wrote: From the imediate window: From the immediate window: --- Regards, Norman "Norman Jones" wrote in message ... Hi Steffi, IF yourvariable MOD 1 = 0 THEN From the imediate window: ? 1.25 Mod 1 0 ? o Mod 1 0 .--- Regards, Norman |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I add an integer to an existing integer? | Excel Worksheet Functions | |||
Calculate mean of test scores from rows of test answers | Excel Discussion (Misc queries) | |||
how do I test for Integer? | Excel Worksheet Functions | |||
Get next Integer value | Excel Programming | |||
Not seeing integer | Excel Programming |