Thursday, August 11, 2016

How to use the SQR Function (WS)

Description

The Microsoft Excel SQR function returns the square root of a number.

Syntax

The syntax for the SQR function in Microsoft Excel is:
Sqr( number )

Parameters or Arguments

number
A positive number that you wish to return the square root for.

Note

  • If a negative number is entered in the number parameter, the SQR function will raise an error.

Applies To

  • Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

Type of Function

  • VBA function (VBA)

Example (as VBA Function)

The SQR function can only be used in VBA code in Microsoft Excel. If you need to calculate the square root within a worksheet formula, try the SQRT function.
Let's look at some Excel SQR function examples and explore how to use the SQR function in Excel VBA code:
=Sqr(25)
Result: 5

=Sqr(30)
Result: 5.47722557505166

=Sqr(2.5)
Result: 1.58113883008419
For example:
Dim LResult As Double

LResult = Sqr(900)

Msgbox LResult
In this example, the variable called LResult would now contain the value 30.

No comments:

Post a Comment