Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
Count Whole / Integer Only? 1.4 1.6 2.7 3.1 Excel Worksheet Functions 3 May 1st 23 07:45 PM
How do I add an integer to an existing integer? Aaron Excel Worksheet Functions 3 December 17th 09 09:46 PM
non-integer scrollbar Brad Charts and Charting in Excel 3 November 7th 07 03:27 AM
integer integer format Excel Worksheet Functions 1 May 3rd 07 06:45 PM
Not seeing integer Martin Wheeler Excel Programming 1 September 4th 03 03:29 AM


All times are GMT +1. The time now is 02:39 PM.

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

About Us

"It's about Microsoft Excel"