What is the square root function in VBA excel? I tried SQRT() and Root() but none of them are working, my Excel version in 2013.
Use the oddly named
VBA.Sqr(n)
where n
is your number for which you want the square root computed. The VBA.
prefix is optional, but it helps descriminate between VBA
and any other library you might have referenced.
Nth root can be obtained with VBA with:
Option Explicit
Function NthRoot(dblNumber As Double, lngRoot As Long) As Double
NthRoot = dblNumber ^ (1 / lngRoot)
End Function
So for square root:
? NthRoot(64, 2)
8
? NthRoot(64.33333, 2)
8.02080606921773
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With