0

So I have followed instructions from multiple posts to create an AppsScript function that allows me to tally votes for responses in a shared google sheet. I am trying to create a collaborative form where employees can submit their feedback, and then instead of having multiples of that feedback additional employees who agree can click a button where it tallies the number of 'votes' that feedback has received.

I have gotten this to work for one row, but how do I use multiple 'increment' functions in the same sheet? Each function would represent responses from a different row, but as you probably know when you are selecting which function to attach to a button (drawing) you are only able to insert the name of the function, which would be the same 'increment' even though the functions are written differently...

Unfortunately I can't share the document because it is hosted on my work platform and I am unable to share it to the public.

Here is what I am working with- essentially I want to have multiple "Agree" buttons with the function representing only that row.

This is the code I have been using:

function increment() {
  SpreadsheetApp
    .getActiveSheet()
    .getRange('C5')
    .setValue(SpreadsheetApp.getActiveSheet().getRange('C5').getValue() + 1);
}

And the code would change to C6, C7, etc. for each row.

I have tried adding each increment code for every row in appscript and it will only tally in the last row. I have tried making separate increment codes on different tabs and it does the same thing.

Please help I have spend hours looking for a response and nothing has helped! google sheet layout

TheMaster
  • 45,448
  • 6
  • 62
  • 85
Alex
  • 11
  • 2
  • Use checkbox instead – TheMaster May 05 '20 at 18:26
  • Related: https://stackoverflow.com/questions/57840757 – TheMaster May 05 '20 at 18:27
  • @TheMaster the problem is there will be 300+ people responding to this sheet so then wouldn't I have to add a ton of checkboxes for each feedback? – Alex May 05 '20 at 18:45
  • Personally, I wouldn't do it with a spreadsheet. I would use a webapp and since it's only for your own employees then I'd publish it in your domain and execute it as me so that they don't require any direct access to the spreadsheet and you can provide them with view only access. The less editors the better. Applies to chiefs as well. – Cooper May 05 '20 at 19:33
  • @Cooper so I actually figured out how to do it and I can edit the permissions on the google sheet so that they are only able to edit the feedback boxes and click on the vote button for other feedbacks. I will share once I am finished it's actually really awesome (in my opinion at least) – Alex May 05 '20 at 19:41
  • @TheMaster since I am super new to this obviously I would love to get your feedback on how it turned out... I put everything in my answer! – Alex May 05 '20 at 20:47
  • @Cooper since I am super new to this obviously I would love to get your feedback on how it turned out... I put everything in my answer! – Alex May 05 '20 at 20:48
  • If your happy with it, that's all that counts – Cooper May 05 '20 at 21:52
  • @Alex *the problem is there will be 300+ people responding to this sheet so then wouldn't I have to add a ton of checkboxes for each feedback?* Why so? – TheMaster May 06 '20 at 05:15

1 Answers1

1

I figured it out!

By writing my own custom function I was able to create this code but change the custom name to match each row number, and assign each button the correct code name matching with that number.

Here is a copy-able version of the Google Doc: https://docs.google.com/spreadsheets/d/12w_Rymf02Bnfi2dnHBiZjLuMV9YOkZ4qtHeSg7grYZc/edit?usp=sharing

And a link to the web app for the appscript if it for some reason doesn't transfer with the sheet (I also linked it in the sheet as well) https://script.google.com/macros/s/AKfycbxE1mL5VKeEGosfS74yzzK2g1WZ6aOj2kdamcwkrIynVPAq38Q/exec

And here is my actual coded functions that are applicable to this sheet although it can be modified for your individual needs:

function vote5() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C5')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C5').getValue() + 1);
}
function vote6() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C6')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C6').getValue() + 1);
}
function vote7() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C7')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C7').getValue() + 1);
}
function vote8() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C8')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C8').getValue() + 1);
}
function vote9() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C9')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C9').getValue() + 1);
}
function vote10() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C10')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C10').getValue() + 1);
}
function vote11() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C11')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C11').getValue() + 1);
}
function vote12() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C12')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C12').getValue() + 1);
}
function vote13() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C13')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C13').getValue() + 1);
}
function vote14() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C14')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C14').getValue() + 1);
}
function vote15() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C15')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C15').getValue() + 1);
}
function vote16() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C16')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C16').getValue() + 1);
}
function vote17() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C17')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C17').getValue() + 1);
}
function vote18() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C18')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C18').getValue() + 1);
}
function vote19() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C19')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C19').getValue() + 1);
}
function vote20() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C20')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C20').getValue() + 1);
}
function vote21() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C21')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C21').getValue() + 1);
}
function vote22() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C22')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C22').getValue() + 1);
}
function vote23() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C23')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C23').getValue() + 1);
}
function vote24() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C24')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C24').getValue() + 1);
}
function vote25() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C25')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C25').getValue() + 1);
}
function vote26() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C26')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C26').getValue() + 1);
}
function vote27() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C27')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C27').getValue() + 1);
}
function vote28() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C28')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C28').getValue() + 1);
}
function vote29() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C29')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C29').getValue() + 1);
}
function vote30() {
  SpreadsheetApp
  .getActiveSheet()
  .getRange('C30')
  .setValue(SpreadsheetApp.getActiveSheet().getRange('C30').getValue() + 1);
}
Alex
  • 11
  • 2