Get the content of first cell in the column after onEdit() activeCell trigger

Asim

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?

user6655984

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get cell number of the first empty column

From Dev

Trigger onEdit() to update the same cell value in Google Sheets

From Dev

WPF DataGrid Trigger on cell content

From Dev

Hide Rows Based on Content of a Cell -issue with onEdit-

From Dev

Removing a html table first column after receving the html content in javascript

From Dev

How do I add the filename after the content of the first column?

From Dev

Get cell by its content

From Dev

Get selected cell content

From Dev

Table view cell reload first cell content

From Dev

VBA Help. Simple code help. Make the activecell the first cell with value>100

From Dev

Get the content of all tags AFTER THE FIRST of the SAME tags - Jsoup

From Dev

Select a column from maximum cell to first cell

From Dev

Xcode Trigger Action after Cell is Clicked in Swift

From Dev

Delete all characters after the first space in a cell all through out the column

From Dev

wpf datagrid apply cell template after first two cells or column index greater than 1 in xaml

From Dev

QML - get tableview cell content

From Dev

Not seeing logs from onEdit trigger

From Dev

Get table cell content based on content of cell in neighbourhood

From Dev

How to disable trigger click after first click

From Dev

DataGrid column size width fit to cell content

From Dev

Separate cell content after "-" for multiple columns at once

From Dev

Find Empty Cell from activecell in a range

From Dev

Select a column by letter from activeCell (without activeCell.EntireColumn)

From Dev

Select a column by letter from activeCell (without activeCell.EntireColumn)

From Dev

Table - size first column based on largest cell

From Dev

PHPExcel - Finding First Column With blank cell

From Dev

openpyxl: Append data to first empty column cell

From Dev

Table - size first column based on largest cell

From Dev

Generate cell pairs based on first row and column

Related Related

  1. 1

    Get cell number of the first empty column

  2. 2

    Trigger onEdit() to update the same cell value in Google Sheets

  3. 3

    WPF DataGrid Trigger on cell content

  4. 4

    Hide Rows Based on Content of a Cell -issue with onEdit-

  5. 5

    Removing a html table first column after receving the html content in javascript

  6. 6

    How do I add the filename after the content of the first column?

  7. 7

    Get cell by its content

  8. 8

    Get selected cell content

  9. 9

    Table view cell reload first cell content

  10. 10

    VBA Help. Simple code help. Make the activecell the first cell with value>100

  11. 11

    Get the content of all tags AFTER THE FIRST of the SAME tags - Jsoup

  12. 12

    Select a column from maximum cell to first cell

  13. 13

    Xcode Trigger Action after Cell is Clicked in Swift

  14. 14

    Delete all characters after the first space in a cell all through out the column

  15. 15

    wpf datagrid apply cell template after first two cells or column index greater than 1 in xaml

  16. 16

    QML - get tableview cell content

  17. 17

    Not seeing logs from onEdit trigger

  18. 18

    Get table cell content based on content of cell in neighbourhood

  19. 19

    How to disable trigger click after first click

  20. 20

    DataGrid column size width fit to cell content

  21. 21

    Separate cell content after "-" for multiple columns at once

  22. 22

    Find Empty Cell from activecell in a range

  23. 23

    Select a column by letter from activeCell (without activeCell.EntireColumn)

  24. 24

    Select a column by letter from activeCell (without activeCell.EntireColumn)

  25. 25

    Table - size first column based on largest cell

  26. 26

    PHPExcel - Finding First Column With blank cell

  27. 27

    openpyxl: Append data to first empty column cell

  28. 28

    Table - size first column based on largest cell

  29. 29

    Generate cell pairs based on first row and column

HotTag

Archive