Google sheets / Google app's script
I'm want to know how to get a Cell, based in my current active Cell. Example:
A table where my active Cell is at G15, im wanna get the value of C15 (same row, but C column) and the value of C3 (same column now). To get the logic, imagines if my current Cell change to (example) H7, so, i would get C7 and H3.
I know It maybe is very simple, but im learning, so, im don't very very good ate that.
CodePudding user response:
Try to add into the cell G15 this formula:
=TEXTJOIN(", ", TRUE, $C15, G$3)
And then copy it from G15 to H7, etc.
CodePudding user response:
You can also achieve this using Apps Script:
function returnVals() {
let sheet = SpreadsheetApp.getActiveSheet();
let activeCell = sheet.getActiveCell();
let row = activeCell.getRow();
let col = activeCell.getColumn();
let colCValue = sheet.getRange(row,3).getValue();
let sameCol = sheet.getRange(3,col).getValue();
console.log(colCValue);
console.log(sameCol);
}
The getActiveCell
method will return the active cell from the sheet and the getRow
and getColumn
will get the row
and the col
of the active cell. Afterwards, based on the row
and col
retrieved, the function above will simply get the values you need by using the getRange
and getValue
methods.
So if the active cell is G17
, the row
will be 17
and the col
will be 7
; therefore:
colCValue
will be the value corresponding to the (17
,3
) range which isC17
;sameCol
will be the value corresponding to the (3
,7
) range which isG3
.