Return only integer part of a number

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

Example: Return only integer part of a number

Return only integer part of a number

METHOD 1. Return only integer part of a number

EXCEL

=TRUNC(B5)
This formula uses the TRUNC function to return only the integer part of a number.

METHOD 1. Return only integer part of a number

VBA

Sub Return_only_integer_part_of_a_number()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'return only the integer part of a number that is captured in a specific cell
ws.Range("C5") = 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 integer part: Select the cell that captures the number from which you want to extract only the integer 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 only the integer 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 integer part of a number

EXPLANATION

EXPLANATION

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

RELATED TOPICS

Related Topic Description Related Topic and Description
How to return only the decimal 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