I have another (somewhat shorter) alternate for your SumR function..
Code:Function SumR(rng As Range) As Double SumR = Evaluate("SUM(ROUND(" & rng.Address & ",2))") End Function
You can view the page at http://www.excelguru.ca/forums/conte...Decimal-Places
Ken Puls, FCPA, FCMA, MS MVP
Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book Master Your Data for Excel and Power BI, or our new Power Query Recipe cards!
Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter
If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.
I have another (somewhat shorter) alternate for your SumR function..
Code:Function SumR(rng As Range) As Double SumR = Evaluate("SUM(ROUND(" & rng.Address & ",2))") End Function
I see my function code did not layout correctly. I'll try again...
Code:Function SumR(rng As Range) As Double SumR = Evaluate("SUM(ROUND(" & rng.Address & ",2))") End Function
I would suggest the precision is an optional parameter
Code:Function SumR(rng As Range, Optional ByVal precision As Long = 2) As Double SumR = Evaluate("SUM(ROUND(" & rng.Address & "," & precision & "))") End Function
That is a good suggestion Bob, especially given how easy it is to incorporate into my function. In my defense, I was responding to the post code which only wanted to round to 2 decimal places, so unthinkingly I just did the same thing.![]()
No defence needed Rick, just thought that as you had taken the trouble to suggest the alternative, I might as well suggest an enhancement to make it a tad more useful - couldn't resist.t
Good to see you here BTW. It is not the busiest site, but you will be a good addition.
Bookmarks