-
At its simplest from a coding point of view:
[vba]Sub blah1()
fx = 23.8
For Each Cll In Worksheets(1).Range("A1:A50")
Cll.Value = Round(Cll.Value * fx, 4)
Next Cll
End Sub[/vba] This will result in the value in each cell being rounded to 4 decimal places but the unrounded number will be gone. Come back if you only want to see a rounded value and the underlying full accuracy retained behind the scenes.
Although speed probably isn't an issue here, the following is some 160 times quicker (if, say, your range is much bigger):[vba]Sub blah2()
fx = 23.8
xxx = Worksheets(1).Range("A1:A50").Value
For i = LBound(xxx) To UBound(xxx)
xxx(i, 1) = Round(xxx(i, 1) * fx, 4)
Next i
Worksheets(1).Range("A1:A50").Value = xxx
End Sub[/vba]
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules