Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I isolate the Fractional part of a number in Excel VB?


I'm a novice writing a VB program in Excel 2003, and I need to isolate
the fractional part of a number. In other words...

Input: 23.0891467
Output: 0.0891467


The only way I know of to do this is (Result = Input Mod 1). The
problem, is that while the Mod Operator works as a Worksheet Function - when
used as a VB Operator, Excel truncates the fractional portion of the result.
This, of course, makes it useless to me.


I need to know the best way to isolate the fractional portion of a
number (with maximum precision), that will work in Excel VB.

Any help will be appreciated! Thanks! :)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I isolate the Fractional part of a number in Excel VB?

Dim Num as double
num = 23.0891467
num = num - int(num)


Is one way.


Cumulous wrote:

I'm a novice writing a VB program in Excel 2003, and I need to isolate
the fractional part of a number. In other words...

Input: 23.0891467
Output: 0.0891467

The only way I know of to do this is (Result = Input Mod 1). The
problem, is that while the Mod Operator works as a Worksheet Function - when
used as a VB Operator, Excel truncates the fractional portion of the result.
This, of course, makes it useless to me.

I need to know the best way to isolate the fractional portion of a
number (with maximum precision), that will work in Excel VB.

Any help will be appreciated! Thanks! :)


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default How do I isolate the Fractional part of a number in Excel VB?

Dim input as double, output as double

Output=Input-int(Input)

Sub GetFraction()
Dim x As Double, y As Double
x = 23.0891467
y = x - Int(x)
Debug.Print y
End Sub

y=8.91467000000006E-02
"Cumulous" wrote:


I'm a novice writing a VB program in Excel 2003, and I need to isolate
the fractional part of a number. In other words...

Input: 23.0891467
Output: 0.0891467


The only way I know of to do this is (Result = Input Mod 1). The
problem, is that while the Mod Operator works as a Worksheet Function - when
used as a VB Operator, Excel truncates the fractional portion of the result.
This, of course, makes it useless to me.


I need to know the best way to isolate the fractional portion of a
number (with maximum precision), that will work in Excel VB.

Any help will be appreciated! Thanks! :)



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
isolate a number in cell with text and numbers User Excel Discussion (Misc queries) 12 May 28th 09 08:57 PM
Removing part of a number in Excel RISXRAY Excel Discussion (Misc queries) 3 September 13th 06 06:55 PM
excel data label format special number characters (part 2) todd Excel Discussion (Misc queries) 1 May 4th 05 04:08 PM
Isolate rows based on highlight (Excel 2003) Alcide Excel Worksheet Functions 2 April 21st 05 05:40 PM
Need Excel to read a text field(part#) and assign a number(commiss sstanton33 Excel Programming 1 March 18th 05 04:08 AM


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