Sqr VBA function – How to calculate square root

Last Updated on January 11, 2023 by token

Sqr VBA function – Description

The Sqr VBA function returns the square root of the argument in the Double data type. With this function you can calculate the root of the second square degree. To calculate the root of a greater degree than the second, i.e. the root of the third or fourth degree, you can’t use this function. You can do this operation by taking a number to the power of (1/3) or (1/4).

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

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 will appear 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

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).

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: