30 Advanced Excel Tips for 2026

Excel Champs / VBA / Top VBA Functions / VBA SQR Function (Syntax + Example)
By Puneet Gogia (Microsoft MVP)

VBA SQR Function (Syntax + Example)

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

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.

Syntax

Sqr(Number)

Arguments

  • Number: A number for which you want to calculate the square root.

Example

To practically understand how to use the VBA SQR function, you need to go through the below example where we have written a vba code by using it:

example-vba-sqr-function
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 cell A1 (625) it has returned 25 which is the square root of 625 in cell B1.

How to Calculate SQUARE ROOT in Excel

Notes

  • 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.
Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel