Reputation: 35
This is a total beginners question. I have created a little script that depending on the active cell and its data, it is supposed to take the values from a specific range in the same row and export them to another sheet in the same document. This is what I have. It works fine but what I don't know how to do is how to increment the range (b8:d8) everytime that I move down to the next row (b9:d9... and so on). The function is going to run upon clicking a custom menu item so basically the user is going to select a cell and click it and move down to the next row, etc. Thanks!
function writing(){
var hojaRegistro = SpreadsheetApp.getActive();
var nombreCurso = hojaRegistro.getActiveCell().getValue();
var name = hojaRegistro.getRange("B8:D8").getValues();
var destino = hojaRegistro.getSheetByName('BDW');
if(nombreCurso==='Breaking Down Writing'){
destino.appendRow([name]);
}
Upvotes: 2
Views: 7654
Reputation: 5051
Grab the active row and insert it into the name range...
var activeRow = hojaRegistro.getActiveCell().getRow();
var name = hojaRegistro.getRange("B"+activeRow+":D"+activeRow).getValues();
Upvotes: 4