I have a script that takes B2 cell as input from google sheets. I set up a list of strings I want to process in rows. I want to "delete cell and shift up" in B2 cell after I run the script. To create a kind of magazine of strings to be input. Any help is greatly appreciated :)
CodePudding user response:
You can do that with Sheet.deleteRow() or Range.deleteCells(), but it would probably make more sense to iterate through the values in column B2:B
with something like this:
function magazine() {
const strings = SpreadsheetApp.getActive().getRange('Sheet1!B2:B').getValues().flat();
strings.forEach(string => myFunctionThatUsesStringInB2(string));
}
CodePudding user response:
Try adding to your code (change "spreadsheet" with the variable you're using for selecting the sheet):
spreadsheet.getRange('B2').deleteCells(SpreadsheetApp.Dimension.ROWS)