Just copied a few macros from Excel (with mods compatible with OO) ... manually added the macro listed below via the editor ... while the macro menu shows the macro name, a cell function is giving me a #NAME error when attempting to call it from a CELL
= gfnRd(123.45678,3) should return 123.457
= gfnRd(123.45678) should return 123.46
Any ideas as to what is causing this issue?
Needing to add a Round() function that emulates the Excel Round() ... Trunc() is apparently unavailable to the Macro
Code: Select all
Public Function gfnRd( D as Double, Optional Dxc as Integer) as Double
dim z as double
dim dc as integer
dim i as integer
dc = 2
if NOT isMissing(Dxc) then dc = Dxc
z = D
if dc >= 0 then
for i = 1 to (dc + 1)
z = z * 10
next
z = int(z)
for i = 1 to (dc + 1)
z = z / 10
if i = 1 then z = int(z - int(z) + .5) + Int(z)
next
end if
gfnRd = z
End Function