1

enter image description here

Suppose I have a table, like so

      A |  B    | E  |
1   Row | Value | 1  | [click here]
2   1   | FALSE |
3   2   | FALSE |
4   3   | FALSE |

I wish to create a button. When clicked, it reads the value of cell E1, in this example is 1. Then it changes the value of row number 1 (the value of E1), in this case cell A2, to FALSE. If the value of E1 is 2, when clicked, it will change the value of cell A3 to FALSE. If the value of E1 is 3, when clicked, it will change the value of cell A4 to FALSE. And so on.

I still have no Idea how to start with the app script. Any help will be appreciated.

6
  • Welcome! It's not entirely clear from your question: is your ultimate goal to create a clickable sheet or learn to write scripts? If you need to easily change TRUE to FALSE and vice versa, then look in the menu Insert - Checkbox
    – JohnSUN
    Sep 2 at 15:13
  • Hi. My goal is to create a clickable button in this sheet. I plan to add it in a different sheet as well, but I figured that will be easy once this one's figured out. Sep 2 at 15:37
  • Yes, it's not difficult at all - 6 minutes of watching the video, 10 minutes of reading the explanations and you can already make this button
    – JohnSUN
    Sep 2 at 15:50
  • Hi, Thanks for pointing that one out. I've actually red that, hence I already made the button as above, and had already figured out that I would also use the code up to var ss = SpreadsheetApp.getActiveSpreadsheet() var sheet=ss.getSheetByName('Sheet1'); but haven't managed to figure the next lines of codes :) Sep 2 at 15:59
  • Supplement your question with this code snippet and someone will definitely show how to get the value from E1 and how to use it further to get the desired cell to read the value from there and write the new value.
    – JohnSUN
    Sep 2 at 16:19

1 Answer 1

0

i've red these articles mentioned, and experimented, and finally got my scripts together

function myFunction() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet()
  var SS = sheet.getSheetByName("Sheet1");
  var selE1 = SS.getRange('E1')
  var nilaiE1 = selE1.getValue()
  var nilaiBaru = nilaiE1+1
  var nilaiEdit = "B" + nilaiBaru
  var selB2 = SS.getRange(nilaiEdit)
  selB2.setValue("FALSE");
  }

i'm still new to this, so i think this code is a bit rough, but it does work. thanks for all your suggestions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.