ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   extract decimal component of number (https://www.excelbanter.com/excel-programming/298782-extract-decimal-component-number.html)

Steve[_42_]

extract decimal component of number
 
Hi, I need to be able to seperate a number into two components, its decimal
and non decimal component.

For example:
Long Price = 108100
ModifiedPrice= Price/1000 (ie. 108.100)

I need to store these value in two different varibales
numbercomponent = ? (108)
decimalcomponent= ? (.100)

Thank you



yogendra joshi

extract decimal component of number
 
Hope this helps...

Sub test()
Dim numbercomponent, decimalcomponent, longprice, modifiedprice

longprice = Range("A1").Value
modifiedprice = longprice / 1000
numbercomponent = Int(modifiedprice)
decimalcomponent = modifiedprice - numbercomponent

MsgBox "Numbercomponent = " & numbercomponent & vbNewLine &
"Decimalcomponent = " & decimalcomponent
End Sub


Thanks,

Yogendra

Steve wrote:

Hi, I need to be able to seperate a number into two components, its decimal
and non decimal component.

For example:
Long Price = 108100
ModifiedPrice= Price/1000 (ie. 108.100)

I need to store these value in two different varibales
numbercomponent = ? (108)
decimalcomponent= ? (.100)

Thank you




Tom Ogilvy

extract decimal component of number
 
LongPrice = 108100
msgbox left(longPrice,len(longPrice)-3) & " - " & right(LongPrice,3)

--
Regards,
Tom Ogilvy

"Steve" wrote in message
...
Hi, I need to be able to seperate a number into two components, its

decimal
and non decimal component.

For example:
Long Price = 108100
ModifiedPrice= Price/1000 (ie. 108.100)

I need to store these value in two different varibales
numbercomponent = ? (108)
decimalcomponent= ? (.100)

Thank you






All times are GMT +1. The time now is 09:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com