Sometimes, when you copy values from websites and paste them into Excel, the sign of the numbers may get reversed due to the way the content is designed in HTML. This issue often happens when copying stock prices or financial data from online sources into Excel. Thankfully, Excel provides several simple and effective methods to fix this. In this tutorial, I’ll explain how to reverse the sign of numbers in Excel using both formulas and VBA code, along with clear examples for better understanding.
You can reverse the sign values of any cell values using the following methods:
- By using the Paste Special Function.
- By using VBA Codes.
Method 1: Using Paste Special Function to Reverse Cells’ Values Sign
- First, you need to enter the value -1 in an empty cell. In this example, the value -1 is entered in cell G3.
- Now, you need to copy cell G3.
- After this, you need to select the Range of cell values (B3:E13) that need to have their sign reversed.
- Once you have selected the range of cells, you need to right-click on the chosen range of cells and choose Paste Special -> Paste Special option.
- In the Paste Special dialog box, choose Multiply from the Operation and then click the OK button.
- Boom. Once you do this, the signs will be reversed in the selected range of cells.
That’s it. This is how you can reverse cell values sign using the Paste Special function option.
Method 2: Using VBA Code to Reverse Cell Values Signs
This is the alternative method to do. You might need to use the VBA code to sync the worksheet values. Using VBA code in Excel, you can easily make all worksheets select the same range and also ensure that the selected range is visible in the same position of the window across all sheets. You can use the keyboard shortcut ALT + F11 to launch the VBA Editor in Excel.
- Firstly, you need to select the range of cell values that need to have their signs reversed (IMPORTANT) as shown in the image.
- Then, you need to use the keyboard shortcut ALT + F11 to launch the VBA Code editor.
- Now, you need to choose the Insert from the Menu bar and choose the Module option as shown in the image below.
-
Now, in the module, you need to paste the VBA Code to reverse the sign of cell values.
Sub Convert() Dim C As Range For Each C In Selection C.Value = -C.Value Next C End Sub
- Now, in the Menu bar, you may see the option “Run“, click on it, and choose the Run Sub/User form F5 option to execute the VBA code. Alternatively, you can use the keyboard shortcut F5 to run the command.
That’s it. This tutorial was originally published on How Can You Reverse Signs of Cell Values in Excel?