I have a SpreadSheet with A1->J1 as TITLES ex.(ProductName, Price etc.). Now my script works but I have problems getting the content of the first row.
Lets say I add a new entry in A20, now the activeCell is A20 but how can I also get the A1 wich is the header and print that with the activeCell. A1,B1,C1 all these are Titles, so when I edit B10 I should print B10+B1.
This is my Code:
var sheet = SpreadsheetApp.getActiveSheet();
var editRange = sheet.getActiveRange();
var editRow = editRange.getRow();
var editCol = editRange.getColumn();
When I edit something I get numbers like A = 1, B =2, C = 3. I just want the content of B1 not the column number. Is this possible?
Apply the method getValue()
to the top cell in the column. For example,
function onEdit(e) {
var topCell = e.range.offset(1-e.range.rowStart, 0).getValue();
Browser.msgBox(topCell);
}
This script makes use of the event object to reduce the number of API calls to two (offset
and getValue
), the rest of information is extracted directly from the object. This is preferable, performance-wise, to a bunch of method calls like getActiveSheet
, getActiveRange
, getRow
, getColumn
...
Offset by 1-e.range.rowStart
means moving up from the edited cell to the first row.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments