# Microsoft Office Application Help - Excel Help forum > Excel Programming / VBA / Macros >  >  How about truncating a decimal as the Trunc() function does?

## skrimpy

Anyone know how to truncate a decimal off using code?(can't round)

----------


## Leith Ross

Hello Skrimpy,

To workaround this problem requires using strings. The code sample shows how to truncated without rounding.

'N  is the Decimal Number (whole or fraction) to truncate
NbrStr = Str(N)
 I = InStr(1, NbrStr, ".")
 N = Val(Left(NbrStr, X - 1))

Where there is a will, there is a way,
Leith Ross

----------


## Norie

Why not just use the Int function? It returns the integer part of a number




```
Please Login or Register  to view this content.
```

----------


## tinyjack

Definitely use Int, you could do this:





```
Please Login or Register  to view this content.
```


TJ

PS You could also just use Application.WorksheetFunction.Trunc

----------


## Leith Ross

Hello,

The best and easiest method is to use the ROUND worksheet function...

Result = WorksheetFunction.Round(_Number, Significant Digits_)

This can be used with the worksheet formulas...
=ROUND(_Number, Significant Digits_)

Just another way to do it,
Leith Ross

----------


## tinyjack

But, Round() does not truncate, it rounds!

TJ

----------


## skrimpy

> Definitely use Int, you could do this:
> 
> .......
> 
> PS You could also just use Application.WorksheetFunction.Trunc



I tried this.  It was not recognized.  Is this another one of those functions that aren't available unless you go to tools and add-ins, like the "Analysis Tool Pak"?

----------


## tinyjack

Well, I have to admit I did not try it and much to my surprise it is not supported by Application.WorksheetFunction.  Learn something new everyday.

I trust the rest of the post has solved your problem.

TJ

----------


## Norie

Int is a VBA function.

And INT is a worksheet function that, as far as I know is available without any add-ins needed.

I think that is not supported by WorkSheetFunction is because it is a VBA function.

----------

