Member-only story

Title: Google Apps Script Example 2: Manipulating Spreadsheet Data

Nishit Maheta
2 min readJun 20, 2023

Introduction:
In our second example of the Google Apps Script series, we will delve into manipulating spreadsheet data using Google Apps Script. With the power of scripting, you can automate data-related tasks, perform calculations, and apply formatting to streamline your workflow. In this blog post, we will explore how to manipulate data in Google Sheets using Google Apps Script.

Step 1: Setting up the Project:
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”.
3. This will open the Script Editor, where you can write and manage your scripts.
4. Give your project a name by clicking on “Untitled Project” at the top left corner.

Step 2: Writing the Code:
1. In the Script Editor, replace the existing code with the following:

function manipulateData() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

// Accessing and modifying data
var data = sheet.getDataRange().getValues();
for (var i = 0; i < data.length; i++) {
var row = data[i];
var modifiedValue = row[0] * 2; // Multiply the first column value by 2
sheet.getRange(i + 1, 1).setValue(modifiedValue); // Update the modified value
}

// Applying formatting
var range = sheet.getRange("A1:A" +…

--

--

No responses yet