Day(s)

:

Hour(s)

:

Minute(s)

:

Second(s)

9 Ways to Square a Number in Microsoft Excel

Are you looking for a way to square a number?

If you work in a field like carpentry, engineering, architecture, or technology, you probably are!

Squaring a number is the mathematical operation of multiplying a number by itself. As an example, a square-sized bedroom measuring 10 feet wide and 10 feet long could be expressed as 100 square feet by multiplying 10 by 10.

This post explores all the different ways to square a number in Microsoft Excel.

Square a Number with the Multiplication Operator

The most straightforward way to square a number is to multiply it by itself using the traditional multiplication operator.

= B3 * B3

The above formula will multiply the number in cell B3 by itself. The asterisk (*) is the operator for multiplication.

You’ve just squared your number from cell B3!

To apply your formula to your other numbers, hover over the lower-right corner of the formula’s cell until your cursor turns to a plus (+), then double-click.

Square a Number with the Carat Operator

The carat operator (^) in Excel is designed for the specific operation of raising a number to a given power such as a square.

= B3 ^ 2

To implement the carat operator on your number in cell B3, select an empty cell and paste the above formula into the formula bar.

The above value 2 following the carat operator is called the exponent of your number. Specifying 2 as your exponent will square the number.

Your number has been squared!

Hover the cursor over the active cell fill handle and double-click to fill the formula down.

Square a Number with the POWER Function

The POWER function is an expert way to calculate a number involving an exponent.

= POWER( B3 , 2 )

To square your number from cell B3 using the POWER function, select an empty cell and paste the above formula into the formula bar.

The second argument is 2. This is the exponent of your number, so always specify 2 here for squaring.

Press Enter when done and see how your number gets squared!

To apply your formula to your other numbers, hover over the lower-right corner of the formula’s cell until your cursor turns to a plus (+), then double-click.

Square a Number with the PRODUCT Function

The PRODUCT function provides general multiplication of values in Excel. Because squaring is just a specific case of multiplication, you can use PRODUCT to square your number.

= PRODUCT( B3 , B3 )

To use PRODUCT against your number in cell B3, select an empty cell and paste the above formula into the formula bar.

Your cell B3 is specified twice in the above formula because you’d like to multiply the B3 number by itself.

Press Enter to calculate the square of your number!

Double-click on the active cell fill handle to copy and paste the formula down your column.

Square a Number with the SUMSQ Function

Though the SUMSQ function is generally used for the summation of squared numbers, its summation feature is optional, leaving you the ability to simply square a single number.

= SUMSQ( B3 )

To leverage SUMSQ for a number in cell B3, select an empty cell and paste the above formula into the formula bar.

You only need to provide your value from the cell B3 and SUMSQ will square it.

Press Enter and behold your squared number!

Double-click on the fill handle to copy down the formula.

Square a Number with Paste Special

Excel has a paste special feature that allows you to multiply copied numbers.

To square numbers using this feature, you copy your numbers to the clipboard, then paste over it with an instruction to multiply it by the clipboard contents.

Here’s how it works for a range of numbers.

  1. Select your range of numbers.
  2. Copy your numbers to the clipboard by selecting Copy under the Home ribbon tab or press Ctrl + C.
  1. While your number range is still selected, go to the Home ribbon tab, drop down the Paste menu and select Paste Special.

Alternatively, you can simply press Ctrl + Alt + V.

This will open the Paste Special menu.

  1. Select Multiple from the Paste Special dialog.
  2. Click on the OK button.

Each number in your selected range has now been squared!

Square a Number with Power Query

Power Query is a powerful data transformation tool for Excel table data.

Once your numbers are arranged in a table, you can create a query that dynamically squares your numbers by using a Power Query formula.

Follow these steps to get started.

  1. Select your range of numbers, including the column header.
  1. Select From Table/Range under the Data ribbon tab.
  1. At the Create Table prompt, click OK to convert your range into a table.
  1. Go to the Transform ribbon tab in the Power Query Editor.
  2. Click on the Scientific menu in the Numbers Column.
  1. Select the Power submenu.
  2. Select the Square option.

Your numbers have now been squared!

You can then place the squared numbers on your sheet.

  1. Under the Home ribbon tab, drop down the Close & Load menu and select Close & Load To.
  1. Choose a destination for your results. For example, choose the Existing worksheet starting at cell D2.
  2. Click OK.

Now your squared numbers appear as a range alongside your original numbers!

Square a Number with VBA

VBA is the code responsible for automating tasks in Excel.

If you’d like to square numbers in a range based on what is currently selected, VBA would be a good way to do that.

Here’s how to explore this option.

  1. First ensure that you see the Developer ribbon tab, since it may be hidden by default.
  1. Go to the Developer ribbon tab.
  2. Click Visual Basic or simply press Alt + F11.
  1. From the Visual Basic editor select the Insert menu.
  2. Select the Module menu item.
Sub SquareNumbers()
Dim selectedRange As Range
Set selectedRange = Application.Selection

For Each cell In selectedRange.Cells
    If Len(cell.Value) > 0 Then
        cell.Value = cell.Value * cell.Value
    End If
Next cell
End Sub
  1. In the new module window, paste the above VBA code.

The code will retrieve each cell in the currently-selected range selectedRange.

The cell’s value will get updated to a multiple of itself, effectively squaring the number. The Len() function is used to skip blank cells to which squaring does not apply.

  1. To run your code, go back to your sheet and select your range of numbers.
  1. Under the View ribbon tab, select Macros.
  1. Select your SquareNumbers macro.
  2. Click the Run button.

Tada! Your numbers have been squared in place!

Square a Number with Office Scripts

Office Scripts is the latest automation language available in Excel for the web if you have a Microsoft 365 business plan.

With Office Scripts, you can create a reusable script to automate the squaring of your numbers in a selected range.

Follow these steps to start your script.

  1. Go to your browser and open your workbook in Excel for the web.
  1. Go to the Automate ribbon tab.
  2. Select the New Script option.
function main(workbook: ExcelScript.Workbook) {
    let range = workbook.getSelectedRange();
    let rowCount = range.getRowCount();
    let colCount = range.getColumnCount();

    for (let row = 0; row < rowCount; row++) {
        for (let col = 0; col < colCount; col++) {
            let currCell = range.getCell(row, col);
            let currValue = currCell.getValue();
            if (currValue.toString().length > 0) {
                currCell.setValue(currValue * currValue);
            };
        };
    };
}
  1. Paste the above script in the Code Editor pane.

The script gets the currently-selected range and loops through each cell.

The cell’s value gets updated to a multiple of itself. This squares the number before moving to the next cell.

This avoids updating blank cells by checking the length of the cell value before multiplying the value.

  1. Save your script by clicking the Save script button.

You can then run your script.

  1. Select your desired range of numbers.
  2. Click the Run button in the Code Editor pane.

The script has now replaced all your selected numbers with their squares!

Conclusions

In this post, you’ve seen many different options to square a number in Excel.

For a workbook whose calculations need to be easily understood, a traditional multiplication operator is a good option. Whereas the carat operator can offer a more concise formula.

The POWER, PRODUCT, or SUMSQ functions will get the job done and integrate better into a workbook that takes advantage of its unique design features.

The paste special option is an interesting way to square numbers in place on your sheet.

The Power Query option could be useful to square numbers as part of a larger workbook data transformation.

Finally, for a fully automated solution that reacts to changing range selections, VBA or Office Scripts is a good option. The choice will generally depend on which Excel app you’re using. Office Scripts is best for the web, while VBA is a good desktop alternative.

Which method do you use when you need to perform square calculations? Let me know in the comments!

About the Author

Barry O'Brien

Barry O'Brien

Barry is a software development veteran with a degree in Computer Science and Statistics from Memorial University of Newfoundland. He specializes in Microsoft Office and Google Workspace products developing solutions for businesses all over the world.

Subscribe

Subscribe for awesome Microsoft Excel videos 😃

John MacDougall

I’m John, and my goal is to help you Excel!

You’ll find a ton of awesome tips, tricks, tutorials, and templates here to help you save time and effort in your work.

Related Posts

Comments

0 Comments

Get the Latest Microsoft Excel Tips

Follow Us

Follow us to stay up to date with the latest in Microsoft Excel!

Subscribe for awesome Microsoft Excel videos 😃