Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Not rounding numbers in VBA


Cells(1, 1) = "3.514"

This gives 4 in A1. Is it possible to pass the actual value without
preformatting the cell?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Not rounding numbers in VBA

You can use this

With Cells(1, 1)
.NumberFormat = "General"
.Value = "3.514"
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl


"serdar" wrote in message ...

Cells(1, 1) = "3.514"

This gives 4 in A1. Is it possible to pass the actual value without preformatting the cell?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Not rounding numbers in VBA

thats ok. my solution was funny:

....=3+0.514


"Ron de Bruin" , haber iletisinde şunları
...
You can use this

With Cells(1, 1)
.NumberFormat = "General"
.Value = "3.514"
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl


"serdar" wrote in message
...

Cells(1, 1) = "3.514"

This gives 4 in A1. Is it possible to pass the actual value without
preformatting the cell?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Not rounding numbers in VBA

sorry im not sure but:

i call smt like:

MoveItem("x", 3.514) or MoveItem("x", "3.514")

and in the moveItem:

With Worksheets("y").Cells(1, 1)
.NumberFormat = "General"
.Value = myValue
End With

....makes it 4 again. It works when i don pass a variable.What happens?
(variable is a Long)



"Ron de Bruin" , haber iletisinde şunları
...
You can use this

With Cells(1, 1)
.NumberFormat = "General"
.Value = "3.514"
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl


"serdar" wrote in message
...

Cells(1, 1) = "3.514"

This gives 4 in A1. Is it possible to pass the actual value without
preformatting the cell?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Not rounding numbers in VBA

Long is short for "long integer" so it will store whole numbers only
which is why this is getting rounded up to 4. Change you data type to
Single or Double.

Hope this helps
Rowan

serdar wrote:
sorry im not sure but:

i call smt like:

MoveItem("x", 3.514) or MoveItem("x", "3.514")

and in the moveItem:

With Worksheets("y").Cells(1, 1)
.NumberFormat = "General"
.Value = myValue
End With

...makes it 4 again. It works when i don pass a variable.What happens?
(variable is a Long)



"Ron de Bruin" , haber iletisinde şunları
...

You can use this

With Cells(1, 1)
.NumberFormat = "General"
.Value = "3.514"
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl


"serdar" wrote in message
...

Cells(1, 1) = "3.514"

This gives 4 in A1. Is it possible to pass the actual value without
preformatting the cell?








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Not rounding numbers in VBA

ahhh..sorry i knew it from C. thanks very much.

"Rowan Drummond" , haber iletisinde sunlari
...
Long is short for "long integer" so it will store whole numbers only which
is why this is getting rounded up to 4. Change you data type to Single or
Double.

Hope this helps
Rowan

serdar wrote:
sorry im not sure but:

i call smt like:

MoveItem("x", 3.514) or MoveItem("x", "3.514")

and in the moveItem:

With Worksheets("y").Cells(1, 1)
.NumberFormat = "General"
.Value = myValue
End With

...makes it 4 again. It works when i don pass a variable.What happens?
(variable is a Long)



"Ron de Bruin" , haber iletisinde şunları
...

You can use this

With Cells(1, 1)
.NumberFormat = "General"
.Value = "3.514"
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl


"serdar" wrote in message
...

Cells(1, 1) = "3.514"

This gives 4 in A1. Is it possible to pass the actual value without
preformatting the cell?






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Not rounding numbers in VBA

You're welcome.

serdar wrote:
ahhh..sorry i knew it from C. thanks very much.

"Rowan Drummond" , haber iletisinde sunlari
...

Long is short for "long integer" so it will store whole numbers only which
is why this is getting rounded up to 4. Change you data type to Single or
Double.

Hope this helps
Rowan

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
Rounding numbers dchmgr Excel Discussion (Misc queries) 1 March 13th 09 04:00 PM
Rounding numbers ac/blue01 Excel Discussion (Misc queries) 3 August 26th 08 09:49 PM
numbers rounding mopat Excel Discussion (Misc queries) 1 November 18th 07 05:00 PM
Rounding numbers up or down Jaco Jacobs Excel Discussion (Misc queries) 1 May 2nd 06 01:16 AM
Rounding numbers then doing a sum of those numbers produces incorrect result. GzusRox Excel Programming 2 July 26th 03 01:42 PM


All times are GMT +1. The time now is 03:18 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"