# VBA SQR Function

Home ➜ VBA Functions LIST (Category Wise) ➜ **How to use the VBA SQR Function (Syntax + Example)**

## 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:

### Syntax

**Sqr(Number)**

### 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

In the above code, we have used the SQR to get the square root of the value that we have in the cell A1 (625) it has returned the 25 which is the square root of 625 in the cell B1.

## Notes

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.