Numerical Calculations. How to Subtract in Google Sheets

Subtracting numbers in Google Sheets is a fundamental skill that is often required when performing numerical calculations or data analysis in a spreadsheet. In this article, we will explore how to subtract in Google Sheets manually and using Google Apps Script. Additionally, we will provide use cases examples to help you understand the practical application of subtraction in Google Sheets.

Manually Subtracting Numbers in Google Sheets #

To perform a subtraction operation manually in Google Sheets, follow these simple steps:

  1. Open Google Sheets and create a new spreadsheet or open an existing one.
  2. Select an empty cell where you want the result of the subtraction to appear.
  3. Type an equal sign (=) to start a formula.
  4. Enter the reference to the cell containing the minuend (the number you want to subtract from).
  5. Type a minus sign (-).
  6. Enter the reference to the cell containing the subtrahend (the number you want to subtract).
  7. Press Enter to complete the formula.

For example, let's say we have the numbers 10 and 5 in cells A1 and B1, respectively. If we want to subtract B1 from A1, we would perform the following steps:

  1. Select an empty cell, for instance, C1.
  2. Type "=A1-B1" without the quotes.
  3. Press Enter.

The result, in this case, will be displayed in cell C1 as 5, which is the difference between 10 and 5.

You can apply the same manual subtraction procedure to other cells by adjusting the cell references and repeating the steps accordingly.

Using Google Apps Script for Subtraction in Google Sheets #

Google Apps Script provides a more flexible and automated way to perform calculations in Google Sheets, including subtraction. To use Google Apps Script for subtraction, follow these steps:

  1. Open Google Sheets and create a new spreadsheet or open an existing one.
  2. Click on "Extensions" in the top menu and select "Apps Script" or "Apps Script editor."
  3. In the Apps Script editor, delete any existing code and paste the following script:
function subtract() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var dataRange = sheet.getActiveRange();
var dataValues = dataRange.getValues();

for (var i = 0; i < dataValues.length; i++) {
var minuend = dataValues[i][0];
var subtrahend = dataValues[i][1];
var difference = minuend - subtrahend;
dataValues[i][2] = difference;
}

dataRange.setValues(dataValues);
}
  1. Save the script by clicking on the floppy disk icon or using the shortcut Ctrl+S (Cmd+S for Mac).
  2. Close the Apps Script editor.
  3. In your spreadsheet, select the range of cells where you want the subtraction operation to be applied.
  4. Click on "Add-ons" in the top menu, move the cursor to "Custom," and select "subtract."

The script will subtract the values in the second column from the values in the first column for each row in the selected range, and the results will be displayed in the third column of each corresponding row.

Use Case Examples #

Here are a few examples to illustrate the practical application of subtraction in Google Sheets:

  1. Financial Analysis: Subtracting expenses from income to calculate net profit.
  2. Sales Reporting: Subtracting returns or discounts from sales revenue to determine net sales.
  3. Inventory Management: Subtracting sold quantities from available quantities to update inventory levels.
  4. Budgeting: Subtracting expenses from the allocated budget to track remaining funds.
  5. Project Management: Subtracting completed tasks from the total number of tasks to monitor progress.

By understanding how to subtract in Google Sheets, you can perform various calculations and analyses, making your spreadsheet more dynamic and useful for different tasks.

In conclusion, subtraction in Google Sheets can be performed manually through simple formulae or automated using Google Apps Script. Understanding how to subtract not only allows you to carry out numerical calculations efficiently but also enables you to analyze and process data effectively in various use cases.

To remove blank rows in Google Sheets, you can follow these steps.
Sorting data by number in Google Sheets can be achieved by using this method.
If you want to sort data by column in Google Sheets, this guide will help you.
Deleting empty rows in Google Sheets is as simple as following these instructions.
To delete rows in Google Sheets, refer to this tutorial for the necessary steps.

Published