Help selecting sheet in Google Sheets code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Help selecting sheet in Google Sheets code?

Iā€™m havjng some trouble selecting a specific sheet as a condition for a function, Iā€™ll try to explain what Iā€™m trying to do. Itā€™s a google apps script code, to sort a table in google sheets. It detects when a cell in column ā€˜Pā€™ is edited (column 16) and then sorts the table according to the data in that column. I have a simple checkbox in column P, so when the checkbox is ticked the entire row of the table is moved to the bottom. The data in this row is then converted into ā€˜contentsOnlyā€™ so that the formulas that previously inhabited the cells in this row no longer operate on new values. This all works perfectly well. The problem Iā€™m having is that Iā€™d like the code to only detect changes to column ā€˜Pā€™ being made in the sheet ā€œPlaygroundā€, but it detects changes across all sheets in the active spreadsheet. So I could go to a different sheet, and if I edit a cell in column ā€˜Pā€™ then the table will be sorted and the bottom row will be converted to ā€˜contentsOnlyā€™ even though I havenā€™t edited anything on the ā€œPlaygroundā€ sheet. I havenā€™t been able to figure out what the problem is, though I suspect it may be in the ā€˜editedCellā€™ or the ā€˜columnToSortByā€™ variables. JavaScript code can be found below. https://code.sololearn.com/cTSu47pZBj1Y/?ref=app

20th Sep 2019, 12:23 PM
Juan
1 Answer
+ 1
Can you please tell me that where is your Excel Sheet 'Playground'?
8th Oct 2019, 12:59 AM
AĶ¢J
AĶ¢J - avatar