0

I'm writing a script where I need to take in a number attached to a name and team, process it as # of Rolls essentially, and then paste the results one by one into a running log. Each team will have it's own columns of name and roll, with multiple teams.

jumpNext() does not seem to customize to a specified column. I suspect this because when I call jumpNext(sheet, 3), the printed text prints staggered, as if it is still using Column 1 or something like .getLastRow() as reference.

I would really appreciate any help with this!
Code in mention:

if (newTeam == teamOne) {
  jumpNext(teamSheet, 1).setValue(newName);
  jumpNext(teamSheet, 3).setValue(rnJesus());
}
function jumpNext(sheet, column) {  
  return sheet.setActiveSelection(sheet.getRange(
               sheet.getDataRange().getHeight() + 1, column));
}

My full program

I based my code on this: Use this little bit of code: jump().

Edit: formatting

  • Welcome. I understand that as new user feel confused as this this site workings are very different from other Q&A sites. First thing to bear in mind is that this site privilege based, meaning that to be able to do some things we should gain the corresponding privilege, in this case, commenting require 50 reputation. As new user you could do what you already did, post a new question including links to the related question but things like asking the post author to "chime in" should be avoided, instead you could look at the author profile and look if he published a way to contact him. – Rubén Oct 24 '18 at 1:59
  • I did look at his profile. I just wanted to continue a discussion that I thought was a good fit for my issue. – M D Oct 25 '18 at 2:02
0

Consider to use something like this:

function jumpNext(sheet, row, column) {  
  return sheet.setActiveSelection(sheet.getRange(row, column)); 
}

where row is the row number , and column the column number, so you will passing the sheet, and coordinates of the destination cell.

  • Thank you so much for your answer. I'm trying the logic and I'm also a little shaky on .setActiveSelection(), how would the jump happen if it takes row as a parameter? – M D Oct 25 '18 at 2:13
0

I think I found a solution. I found inspiration from this Javascript trick and combined the printing and jumping into one function.

function setNext(sheet, letterCol, nameCol, rollCol, newName) {
  var values = sheet.getRange(letterCol + "1:" + letterCol).getValues();
  var last = values.filter(String).length + 1;
  sheet.getRange(last, nameCol).setValue(newName);
  sheet.getRange(last, rollCol).setValue(rnJesus());
}

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.