Sqr VBA function – How to calculate square root

1. Sqr VBA function – Description

The Sqr VBA function returns the square root of the argument with the Double data type. With this function we can calculate the root of the second degree. To calculate the root of a greater degree than the second, i.e. the root of the third or fourth degree , we will not do it using this function. We can do this by taking a number to the power of (1/3) or (1/4).

2. VBA Sqr Function – Syntax

'officeinside.org
Sqr (Number As Double) As Double

Number : A number with the Double data type.

Function return : Double / Numeric value

3. VBA Sqr function – Example

How to use Sqr function in VBA Excel? Below are examples of using the Sqr function in the VisualBasic Editor.

Example 1: Using the Sqr function – extracting the square root. The result in the MsgBox window

'officeinside.org
Dim DblNumber As Double
DblNumber = 100
MsgBox Sqr (DblNumber)

Example 2: Result in a worksheet cell. Extracting the VBA root

'officeinside.org
Dim DblNumber As Double
DblNumber = 100
Range ("A1") = Sqr (DblNumber)
Excel VBA functions - SQR VBA function
Excel VBA functions – SQR VBA function

4. VB Sqr Function – Additional informations

  • To calculate a root other than the second degree, use exponentiation, e.g. the third-degree root of 27 is 27 ^ (1/3).

5. SQR VisualBasic function – Where to use?

The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016 , Excel 2019.

The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions .

Leave a comment

Your email address will not be published. Required fields are marked *

%d bloggers like this: