How to get cell value in Google Sheets using apps script

There are different ways to get the cell values. This article shows you different ways to get cell values from the Google Sheet. Some of the methods (like getCell(row, col) ) will be easier if you want to iterate through the cells.

Get selected cell value in your Google Sheet Script

First, let us add a menu item to your Google sheet so that it is easy for us to try the functions.

Now we have to add getCurrentCellValue() function. This function will get the value of the currently selected cell and then show it in a message box.

In order to make it a little more informative, let us show the cell’s A1 notation and then its value.

Get Cell by row and column

You can get a a range by using this function sheet.getRange(row,col)
In order to get the value, use the getValue() function. example:

Another example

Get Cell by A1 notation and then get its value

Getting value using A1 notation is also similar.

First, you have to get the range. Then do getValue on the range.

Example:

Or in two steps:

Sample Sheet:
See the sample sheet here

Make a copy and go to Tools → Script editor to make changes.

Full script code:
https://gist.github.com/prasanthmj/4fcee6c6e3c4d3f0bbdbf725db04a937

Leave a Reply 0 comments

Leave a Reply: