Return only decimal part of a number

This tutorial shows how to return only the decimal component of a number through the use of an Excel formula, with the TRUNC function, or VBA.

Example: Return only decimal part of a number

Return only decimal part of a number

METHOD 1. Return only decimal part of a number

EXCEL

=B5-TRUNC(B5)
This formula uses the TRUNC function to return the integer part of the number which is then removed from the whole number to return only the decimal part of the number.

METHOD 1. Return only decimal part of a number

VBA

Sub Return_only_decimal_part_of_a_number()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'return only the decimal part of a number that is captured in a specific cell
ws.Range("C5") = ws.Range("B5") - Fix(ws.Range("B5"))

End Sub

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code.
Number from which to extract decimal part: Select the cell that captures the number from which you want to extract the decimal part by changing the cell reference ("B5") in the VBA code.
Worksheet Selection: Select the worksheet which captures the cell from which you want to extract the decimal part by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.

Explanation about how to return only decimal part of a number

EXPLANATION

EXPLANATION

This tutorial shows how to extract only the decimal part of a number by using an Excel formula, with the TRUNC function, or VBA.
FORMULA
=number-TRUNC(number)
ARGUMENTS
number: The number from which to extract only the decimal part.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to return only the integer component of a number using Excel and VBA
How to return the last numeric value in a column using Excel and VBA
How to return the last numeric value in a row using Excel and VBA
How to return the first word from a string using Excel and VBA
How to return the highest value from a range of values using Excel and VBA