J
James Bond
Hello. I am having a little trouble with a simple little function I wrote
to handle significant figures in excel. I just created a VBA module with
this simeple code;
Function Sig(BaseNum, NumSigDig)
Sig = Round(BaseNum, NumSigDig - Len(Int(BaseNum)))
End Function
The intended functionality of this would be something like if R1C1=
42.0037 then =sig(a1,5) would return the number 42.004 (rounded to 5
significant digits).
Now this function mostly seems to work like a charm (there are some
limitations in this implementation but they are expected and not the
subject of this post)
What really has me stumped is the function seems to only work where
BaseNum (the number to rounded) is less than 10000 (so 9999.9999999 works
okay, but not 10000).
I am very new to VBA so I don't understand how data types are being
handled well enough to troubleshoot this problem. Any advice would be
greatly appreciated.
Thanks
James
to handle significant figures in excel. I just created a VBA module with
this simeple code;
Function Sig(BaseNum, NumSigDig)
Sig = Round(BaseNum, NumSigDig - Len(Int(BaseNum)))
End Function
The intended functionality of this would be something like if R1C1=
42.0037 then =sig(a1,5) would return the number 42.004 (rounded to 5
significant digits).
Now this function mostly seems to work like a charm (there are some
limitations in this implementation but they are expected and not the
subject of this post)
What really has me stumped is the function seems to only work where
BaseNum (the number to rounded) is less than 10000 (so 9999.9999999 works
okay, but not 10000).
I am very new to VBA so I don't understand how data types are being
handled well enough to troubleshoot this problem. Any advice would be
greatly appreciated.
Thanks
James