Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Determining an Integer Value.
Written by Allen Wyatt (last updated April 24, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003
VBA, true to its BASIC roots, provides a function to return the integer value of an expression. This means that anything to the right of the decimal point is truncated. Thus, if a formula would normally result in a value such as 18.73, then the integer value of that formula would result in 18.
The syntax for the integer function is as follows:
x = Int(y)
where x is the result and y is a value or an expression that evaluates to a value.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2352) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Determining an Integer Value.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Want a quick way to convert positive values to negative and vice versa? You can create your own plus/minus button by ...
Discover MoreYou can create macros that run whenever Excel detects a certain event happening within an entire workbook. This tip ...
Discover MoreWhen creating a workbook to be used by others, you may want any worksheets they add to the workbook to contain some ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2015-09-26 10:40:42
Rick Rothstein
The Int function does not "truncate" the floating point number, rather, it returns the first integer less than or equal to the given number. For positive numbers, the effect is to truncate the decimal part, but for negative numbers, not so... Int(-18.73) becomes -19. The VB function that works the way you described by truncating the decimal part for all values is the Fix function... Fix(18.72) becomes 18 and Fix(-18.73) becomes -18.
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments