I've found a LOT of scripts that will take data from a Google Sheet and create a Google Doc, but I need a paragraph (really just a few sentences) generated into the Sheet itself. We create web pages for people who enter their information into a Google Form (name of their store, location, brands carried, etc.), we do this by exporting the Google Sheet into a .csv file, and uploading the file which generates the pages. So we need the paragraph to be in the Google Sheet.
I need a script that will give me a paragraph that says:
Column D is a "OUR BRAND" dealer located in Column H. Column D also sells Column T.
I've been trying to figure out this script for hours piecing together what I've found elsewhere and it seems like every time I sort out one bit, I screw up another bit. It's a mess:
function onEdit() {
var activeSheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = activeSheet.getSheetByName("All Dealers");
var cell = sheet.getActiveCell();
var row = cell.getRow();
var col = cell.getColumn();
// Fetch the range of cells
var dataRange = sheet.getRange(row, col)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var dealerName = row[0]
var city = row[1]
var brand = row[2];
}
var body = 'dealerName' + "is a OURBRAND located in" + 'city' + 'dealerName' + "also sells" + 'brand';
SpreadsheetApp.getActiveSheet().getRange("AI"+row).setValue('body');
}
body = dealerName + "is...
and so on. Also, this task does not require a script at all. – user3717023