Return to VBA Code Examples

VBA Sqr Function

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on September 12, 2023

Sqr Function

Returns the square root of a number.

Simple Sqr Examples

Sub Sqr_Example()
    MsgBox Sqr(100)
End Sub

This will return 10

Sqr Syntax

In the VBA Editor, you can type  “Sqr(” to see the syntax for the Sqr Function:

The Sqr function contains an argument:

Number: Any valid numeric expression greater than zero.

Examples of Excel VBA Sqr Function

MsgBox Sqr(0.25)

Result: 0.5

MsgBox Sqr(25)

Result: 5

MsgBox Sqr(-25)

Result: Run-time error ‘5’

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as

Learn More!

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples