What is VBA SQR Function
The VBA SQR function is listed under the math category of VBA functions. When you use it in a VBA code, it returns the square root of the number supplied. In simple words, you can calculate the square root of a number with it.
how to use it
To use VBA's SQR function you need to understand its syntax and arguments:
- Number: A number for which you want to calculate the square root.
Example to use SQR Function in VBA
To practically understand how to use VBA SQR function, you need to go through the below example where we have written a vba code by using it:
Sub example_SQR() Range("B1").Value = Sqr(Range("A1")) End Sub
Below are some important points which you need to take care while using SQR function in VBA.
- If the value specified is a value other than a number or a number that can’t be recognized as a number, VBA will return the run-time 13 error.
- If the number supplied is a negative number then VBA will return a run-time 5 error.
About the Author
Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.