 Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Creating a Plus/Minus Button.

# Creating a Plus/Minus Button by Allen Wyatt
(last updated December 30, 2019)

On some calculators there is a little button that can come in very handy: the plus/minus button. This button, when pressed, will switch whatever value is on the display between its positive and negative values. For instance, if the display shows the number 57, then pressing the button will change the display to -57. Pressing it again will switch the value back to 57.

If you would like a "button" that does this in Excel, you'll quickly find that there is none built into the program. You can quickly create one, however, by using a macro:

```Sub PlusMinus1()
Dim cell As Range

For Each cell In Selection
If Application.IsNumber(cell) Then
cell.Value = cell.Value * -1
End If
Next cell
End Sub
```

Note that the macro simply steps through whatever range of cells you selected when the macro started. Each cell is checked to see if it contains a number. If it does, then the value of that number is multiplied by -1. The result is a switch in sign for the number.

One drawback to the macro is that if the cell contains a formula, that formula is converted to a value and then multiplied by the -1 value. You may not want to lose your formulas. In that case, you could rely on a more discriminating macro, one that checks to see if the cell contains a formula or not. If not, then it is simply multiplied by -1. If so, then the formula is adjusted so that the result is multiplied by -1.

```Sub PlusMinus2()
Dim cell As Range

For Each cell In Selection
If Left(cell.Formula, 1) = "=" Then
Cell.Formula = cell.Formula & " * -1"
Elseif Application.IsNumber(cell) Then
cell.Value = cell.Value * -1
End If
Next cell
End Sub
```

You can assign either of these macros to a shortcut key or to a toolbar button to make it easy to use at any time.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3256) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Creating a Plus/Minus Button.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Selecting Random Names

Got a tone of names from which you need to select a few random names? There are several ways you can extract what you ...

Discover More

Controlling Widows and Orphans

Got singular lines at the bottom or top of a page? These are often referred to as widows and orphans, and Word allows you ...

Discover More

A common use to which teachers put Word is to create tests and answer sheets. By imaginatively applying the features of ...

Discover More Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

Determining How Many Windows are Open

Does your macro need to know how many windows Excel has open? You can determine it by using the Count property of the ...

Discover More

Determining an ANSI Value in a Macro

Need to know the character code used for a particular character? In a macro you can use the Asc function to determine the ...

Discover More

Counting Commas in a Selection

If you have a range of cells in which you want to count all the commas, there are several ways you can derive the figure ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 2?

2015-06-22 03:06:10

Phill

This works, but will mess up any formulae that you use (especially if you are not using a built in keyword - such as SUM).

Howerver a few additions and changes to the 2nd Macro PlusMinus2 can fit it :-->

Sub PlusMinus2()
Dim cell As Range

For Each cell In Selection
If Mid(cell.Formula, 2, 1) = "-" Then
cell.Formula = "=" & Right(cell.Formula, Len(cell.Formula) - 2)
ElseIf Left(cell.Formula, 2) = "=(" Then
cell.Formula = "=-" & Right(cell.Formula, Len(cell.Formula) - 1)
ElseIf Left(cell.Formula, 1) = "=" Then
' if no "(" then add it, so whole formula is changed, not just last number.
cell.Formula = "=-(" & Right(cell.Formula, Len(cell.Formula) - 1) & ")"
ElseIf Application.IsNumber(cell) Then
'Not a formula, so change value.
cell.Value = cell.Value * -1
End If
Next cell
End Sub

##### This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.