Answer the question
In order to leave comments, you need to log in
How to make a script to select the entire line GOOGLE SHEETS?
At first I wrote a script for color formatting a row in a table, but I use a script (see below). All other formatting flies. Therefore, the idea came up to create a script (by clicking on any cell in the table, the key combination Shift + Space is automatically used ). But I could not write such an event in any way.
function onSelectionChange() {
let ss = SpreadsheetApp.getActiveSpreadsheet();
let ws = ss.getActiveSheet();
let activeCell = ws.getActiveCell().getRow();
ws.getRange(2, 1, 1000, ws.getLastColumn()).clearFormat();
ws.getRange(activeCell, 1, 1, ws.getLastColumn()).setBackground("yellow")
}
Answer the question
In order to leave comments, you need to log in
To avoid formatting, do not use
ws.getRange(2, 1, 1000, ws.getLastColumn()).clearFormat();
//...
"sheets": {
"macros": [{
"menuName": "macros1",
"functionName": "myFunction",
"defaultShortcut": "Ctrl+Shift+Alt+1"
}]
}
//...
function onSelectionChange() {
let ss = SpreadsheetApp.getActiveSpreadsheet();
let as = ss.getActiveSheet();
let ac = as.getActiveCell();
let row = ac.getRow();
as.getRange(row+":"+row).setBackground("yellow");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question