Excel VBA and the TRUNC Function

Excel has a TRUNC function that truncates numbers. For example =TRUNC(15.75) returns 15. It doesn’t round it just removes the fraction leaving the whole number. Excel VBA does not have the TRUNC function. It does have the Fix function that works the same.

The Fix function removes any decimals leaving the whole number unchanged.

Be careful using the Int function which looks like it does the same calculation as Fix, but it handles negatives differently.

Fix(9.2) returns 9

Int(9.2) returns 9

Fix(-9.2) returns -9

Int(-9.2) returns -10

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.