0

I am trying to make a macro to add 1 to a single cell in google sheets WITHOUT CLICKING, and with a keyboard. Let me explain exactly what I'm trying to do overall:

I'm attempting to tally a total of 20 different values. I have to do this around 1200 times, per row. so I would like to be able to press 1 on my keyboard (or control shift 1 or whatever the macro allows me to do) to add +1 to column 1, and press 2 on my keyboard to add +1 to column 2, and so on and so forth. I have found solutions to add on screen buttons, but I would prefer if I could just press a single key on my keyboard. if thats not possible, thats ok, I am relativley new to sheets

Yall gonna make fun of me but I tried to do

/** @OnlyCurrentDoc */
function roll1() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('C3').activate();
  spreadsheet.getCurrentCell().setValue(+1);
};

and it just set the cell value to 1 instead of adding 1 to the value

  • 2
    "total of 20 different values....around 1200 times, per row" doesnt make sense. are you trying to click this button 20 times or 1200 times? perhaps you can illustrate with a screenshot of example. perhaps you can use checkboxes and tally by checkbox, would make more sense than clicking a button and if you click incorrectly how you undo it? – Mr Shane Oct 30 '22 at 06:24
  • @MrShane So I have a total of 1200 items, each divided into 20 categories. So like, in the end I will have like, item 1 will have 100, item 2 will have 50, item 3 will have 250, etc... all the way up to item 20 – Xander Ashe Oct 30 '22 at 06:34
  • Welcome to [so]. The previous answer from the linked question show how to increment a cell value. Adapt it to your specific needs. If you need further help. please briefly describe the spreadsheet structure, add a table showing sample data and another showing the expected result. Also show you attempt to use what you learned from the linked question, and if it was not clear tell us what was not clear. – Rubén Oct 30 '22 at 07:12

0 Answers0