How to Square a Number in Excel [4 Awesome Methods]

by

Square a number is a common mathematics operation. In excel, if you want to know “How to Square a Number in Excel,” then this tutorial will be very useful.

In excel, you can do multiple ways to Square a Number.

  1. Exponent
  2. POWER function 
  3. Multiplication
  4. VBA

We will see each of these methods in this article. 

How to Square a Number in Excel Using Different Methods

Square a Number in Excel How to Square a Number in Excel [4 Awesome Methods]

Square a Number in Excel using Exponent

To square a number in a cell, you can use the exponent operator or caret symbol. By using this method, you can square as well can triple and more.

To Square the Value in A1, you can use the below formula with the caret symbol. The exponent symbol is with the number 6. To type the caret symbol, you need to press Shift + 6 [Same for both Windows and Mac]

=A1^2 

  • Follow the below steps to do this in your excel file.
  • First, select the cell that you want to type formula for Square Root.
  • Type the formula as =A1^2
  • Press Enter

Now you can see the square root of the A1 cell value.

To apply the formula to the entire column, select the cell, and when you see the + double click on its formula will be applied to the entire column.

Complete guide on how to apply the formula to entire columns.

Instead of 2, you can try with three or more numbers based on the number the output will come.

Example:  A1 cell contains two, and if we used the formula A1^ 3, we would get output as 8.

so A1=2

A2^3 = 2 * 2 * 2 = 8

Square a Number in Excel using Power Function

Above method, we used exponent now we try with a power function. The power function is excel inbuilt function that we can use for square.

=POWER(A1,2) 

Follow the below steps to do this in your excel file.

  1. First, select the cell that you want to type formula for Square Root.
  2. Type the formula as = POWER(A1,2)
  3. Press Enter Key or return key
  4. Now you can see the square root of the A1 cell value.

Example: A1 cell contains two, and if we used the formula A1^ 3, we would get output as 8.

so A1=2

POWER^3 = 2 * 2 * 2 = 8

Square a Number in Excel using Multiplication

Above method or Excel function now we will see to square the number using multiplication. A square number is the multiplication of the same number once again.

Eg. A2^3 = power(A2,3) = A2*A2*A2

  1. First, select the cell that you want to type formula for Square Root.
  2. Enter the formula as = POWER(A1,2)
  3. Once entered the formula, press Enter Key
  4. Now you can see the output.

To apply the formula to the remaining column, drag it down using the fill handle.

These are the inbuilt and Maths function to square the number to find the raise of the power. These functions are easy to use and straightforward.

Now let see a complex or advanced method using VBA.

Square a Number using VBA

Using Excel VBA, you can automate your simple daily tasks. No, we will see how to square a number in excel at the same cell using VBA.

Steps

We need to create right-click function that triggers this square number sub module.

  • First, open your Excel sheet. [If not opened]
  • Press Alt + F11 function key to open the VBA editor.
  • Now you can see a window like this.
  • From the left side project menu, select ThisWorkbook and double click it.

Now you paste the below methods Workbook_Deactivate and Workbook_SheetBeforeRightClick in your excel sheet at Excel Worksheet. The below code has two modules. One will create a Right-click function, and another one deletes the process when the excel workbook gets deactivated.

Square a Number using VBA How to Square a Number in Excel [4 Awesome Methods]

Using the below submodules, we will achieve that.

 Private Sub Workbook_Deactivate()
     On Error Resume Next
     With Application
 .CommandBars("Cell").Controls("Square Number").Delete
     End With
     On Error GoTo 0
 End Sub 

Create Menu

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
     Dim cmdBtn      As CommandBarButton
     On Error Resume Next
     With Application
         .CommandBars("Cell").Controls("Square Number").Delete
         Set cmdBtn = .CommandBars("Cell").Controls.Add(Temporary:=True)
     End With
     With cmdBtn
         .Caption = "Square Number"
         .Style = msoButtonCaption
         .OnAction = "ThisWorkbook.Square_Number"
     End With
     On Error GoTo 0
 End Sub

After creating the submodule, we need to make a method the squares the number in the active cell. If you select apart from number, then you will get a warning message.

Sub Square_Number()
     int_cellvalue = ActiveCell.Value
     If IsNumeric(int_cellvalue) Then
         ActiveCell.Value = int_cellvalue * int_cellvalue
     Else
         MsgBox "Sorry You need an Integer To Square a Number."
     End If
 End Sub
How to Square a Number in Excel

Using the VBA submodule, you can square a number in the same cell. This VBA is a bit complex method. If you square a number frequently and want it in the same cell, this method will be handy.

Conclusion

In this article, we saw four ultimate ways to square a number. If you know any other method to a square number, please share with us.

Leave a Comment