Variable in getRange on Google Sheets

Viewed 191

I want to capture the information of the variable "row" and use it in getRange to find the data that are in the rows that were selected in the variable, for example I already defined the column I want to use, for example "A" and I want getRange to get the data from cell "A2", where the number 2 was selected in the variable "row", but I am not able to get this row value to be processed in the script, could someone help me select this?

function InputBox() {

var ui = SpreadsheetApp.getUi(); var coluna = ui.prompt("Qual coluna vocĂȘ deseja copiar?", ui.ButtonSet.OK);

Logger.log(coluna.getResponseText()); Logger.log(coluna.getSelectedButton());

Tks!

1 Answers

You can get the cell value using getValue() on Apps Script. You can add this code for getting the value in a cell which is defined by your variables col and row.

var value = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(<Sheet Name>).getRange(col+row).getValue()

This gets the value of the cell referring to the concatenated col and row("A"+"2").

Related