Link to home
Start Free TrialLog in
Avatar of thandel
thandel

asked on

Truncating a range

I have the following code that selects a desired range:

Range(Range("StartEntry").Offset(0, 2), Range("TOTSALE").Offset(-2, 0)).Select

I would like to truncate antying in that range to only 2 decimal places.

Is this possible and if so how with VBA.
Avatar of nutsch
nutsch
Flag of United States of America image

You can loop and round all cells in the range, like this

dim rgLoop as range

for each rgLoop in Range(Range("StartEntry").Offset(0, 2), Range("TOTSALE").Offset(-2, 0)).cells
rgloop=round(rgloop,2)
next rgloop

Open in new window

Avatar of thandel
thandel

ASKER

Thanks but not looking to round, need to truncate.
Then this

dim rgLoop as range

for each rgLoop in Range(Range("StartEntry").Offset(0, 2), Range("TOTSALE").Offset(-2, 0)).cells
rgloop=int(rgloop*100)/100
next rgloop

Open in new window

Avatar of thandel

ASKER

Well its truncating but also making each empty cell's value "0.00"
ASKER CERTIFIED SOLUTION
Avatar of nutsch
nutsch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial