Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get next Integer value
If I Dim i As Integer
and then test "A1" for its' value and if the value in "A1" is 3.00000000000000 and 1 How can I return i = 4 , please? ie any value 3 but < 4 returns 4 Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get next Integer value
Stuart,
I'm not sure what your question is. A variable declared as Integer can only hold whole numbers, no fractional part, so the variable will be either 3 or 4, but never a number between the two. If you need to include a fractional part, declare the variable as Double. "Stuart" wrote in message ... If I Dim i As Integer and then test "A1" for its' value and if the value in "A1" is 3.00000000000000 and 1 How can I return i = 4 , please? ie any value 3 but < 4 returns 4 Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get next Integer value
i = -int(-3.000000000000001)
-- Rob van Gelder - http://www.vangelder.co.nz/excel "Stuart" wrote in message ... If I Dim i As Integer and then test "A1" for its' value and if the value in "A1" is 3.00000000000000 and 1 How can I return i = 4 , please? ie any value 3 but < 4 returns 4 Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get next Integer value
Or:
Dim i As Integer i = WorksheetFunction.Ceiling(Range("A1"), 1) -- Vasant "Rob van Gelder" wrote in message ... i = -int(-3.000000000000001) -- Rob van Gelder - http://www.vangelder.co.nz/excel "Stuart" wrote in message ... If I Dim i As Integer and then test "A1" for its' value and if the value in "A1" is 3.00000000000000 and 1 How can I return i = 4 , please? ie any value 3 but < 4 returns 4 Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get next Integer value
If he declares it as integer, it will implicitly do what is advised here, it
cannot be 3.000000000000001 Bob "Rob van Gelder" wrote in message ... i = -int(-3.000000000000001) -- Rob van Gelder - http://www.vangelder.co.nz/excel "Stuart" wrote in message ... If I Dim i As Integer and then test "A1" for its' value and if the value in "A1" is 3.00000000000000 and 1 How can I return i = 4 , please? ie any value 3 but < 4 returns 4 Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get next Integer value
Many thanks all.
Used Vasant's solution and appears fine. Did not post clearly. Here was the situation: Col A contains text values or integers and empty cells. Each numeric value represents the end of a 'page' and they are sequential. If the last numeric value in the range is less than 25 then they will all transfer to 1 Collection page. If more than 24 then I need to find the number of Collection pages. I'm using: CollectionPages = LastPageNo / 24 'returns a decimal value and CollectionPages = WorksheetFunction.Ceiling(CollectionPages, 1) which increments CollectionPages to the next integer, if need be. Regards. "Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ... Or: Dim i As Integer i = WorksheetFunction.Ceiling(Range("A1"), 1) -- Vasant "Rob van Gelder" wrote in message ... i = -int(-3.000000000000001) -- Rob van Gelder - http://www.vangelder.co.nz/excel "Stuart" wrote in message ... If I Dim i As Integer and then test "A1" for its' value and if the value in "A1" is 3.00000000000000 and 1 How can I return i = 4 , please? ie any value 3 but < 4 returns 4 Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get next Integer value
Not sure what you mean?
This example rounds up. Sub test() Dim dbl As Double, i As Long dbl = 3.1 i = -Int(-dbl) MsgBox i End Sub (using 3.1, 3.000000000000001 is precise for VBA) -- Rob van Gelder - http://www.vangelder.co.nz/excel "Bob Phillips" wrote in message ... If he declares it as integer, it will implicitly do what is advised here, it cannot be 3.000000000000001 Bob "Rob van Gelder" wrote in message ... i = -int(-3.000000000000001) -- Rob van Gelder - http://www.vangelder.co.nz/excel "Stuart" wrote in message ... If I Dim i As Integer and then test "A1" for its' value and if the value in "A1" is 3.00000000000000 and 1 How can I return i = 4 , please? ie any value 3 but < 4 returns 4 Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get next Integer value
I suspect Bob is talking about the argument to int being an integer,
therefore it can't be 3.0000000000000001 or what ever There was some concern that Stuart was saying an integer had a decimal portion. Stuarts later posting shows his number is produce by a division and therefore is not a decimal, but he wants to round up to the next higher integer. 3.00000000001 pages requires a total of 4 pages. -- Regards, Tom Ogilvy "Rob van Gelder" wrote in message ... Not sure what you mean? This example rounds up. Sub test() Dim dbl As Double, i As Long dbl = 3.1 i = -Int(-dbl) MsgBox i End Sub (using 3.1, 3.000000000000001 is precise for VBA) -- Rob van Gelder - http://www.vangelder.co.nz/excel "Bob Phillips" wrote in message ... If he declares it as integer, it will implicitly do what is advised here, it cannot be 3.000000000000001 Bob "Rob van Gelder" wrote in message ... i = -int(-3.000000000000001) -- Rob van Gelder - http://www.vangelder.co.nz/excel "Stuart" wrote in message ... If I Dim i As Integer and then test "A1" for its' value and if the value in "A1" is 3.00000000000000 and 1 How can I return i = 4 , please? ie any value 3 but < 4 returns 4 Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.586 / Virus Database: 371 - Release Date: 12/02/2004 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Count Whole / Integer Only? | Excel Worksheet Functions | |||
How do I add an integer to an existing integer? | Excel Worksheet Functions | |||
non-integer scrollbar | Charts and Charting in Excel | |||
integer | Excel Worksheet Functions | |||
Not seeing integer | Excel Programming |