Google sheets write to cell

Google sheets write to cell

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.

function onOpen() 
{
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('GetValues')
      .addItem('get current', 'getCurrentCellValue')
      .addToUi();
}

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.

function getCurrentCellValue()
{
  var vv = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();
  
  SpreadsheetApp.getUi().alert("The active cell value is "+vv);
}

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

function getCurrentCellValue()
{
  var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
  var a1 = cell.getA1Notation();
  var val = cell.getValue();
  
  SpreadsheetApp.getUi().alert("The active cell "+a1+" value is "+val);
}

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:

var row = 5;
var col = 2;

var value = SpreadsheetApp.getActiveSheet().getRange(row, col).getValue();

Another example

var value = SpreadsheetApp.getActiveSheet().getRange(12, 2).getValue();

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:

var value = SpreadsheetApp.getActiveSheet().getRange('B12').getValue();

Or in two steps:

var range = SpreadsheetApp.getActiveSheet().getRange('B12');
var value = range.getValue();

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

Watch Video – Jump to Specific Cell/Range in Google Sheets

As you start working with more data in Google Sheets, you may feel a need to have a quick way to jump to a specific cell or a range.

For example, you may want to quickly refer to a specific cell that has some relevant value or a specific row/column.

Fortunately, there are a few neat ways that allow you to do just that,

In this tutorial, I will show you two simple ways to quickly jump to a specific cell in Google Sheets (or jump to a specific range, row or column).

So let’s get started!

  • Jump to Cells Using the ‘Go To Range’ Option
  • Creating Links to Jump to Cell/Range in the Same Sheet
  • Creating Links to Jump to Cell/Range in the Other Sheet

Jump to Cells Using the ‘Go To Range’ Option

In Google Sheets, there is a way to simply type the cell reference (or the range reference or row/column number) and quickly jump to it.

This can be done using the ‘Go To Range’ feature in Google Sheets.

But the issue is that you will not be able to find it anywhere in the existing options.

Let me show you two ways to get the ‘Go To Range’ option and then use it to jump to any cell/range in Google Sheets.

Using Help to Find ‘Go To Range’

Let’s say you want to quickly go to cell A1 in Google Sheets.

Below are the steps to get the ‘Go To Range’ search box and jump to cell A1:

  1. Open the Google Sheets document
  2. Click on the Help option in the menu
    Google sheets write to cell
  3. In the search bar that appears, type – ‘Go To Range’.
  4. Click on the Go To Range option. This will open the Go to search box at the top-right part of the Google Sheets worksheet.
    Google sheets write to cell
  5. In the search box, enter A1
    Google sheets write to cell
  6. Hit the Enter key.

The above steps would take you to cell instantly.

You can also use the same steps to jump to any specific range or row/column.

Below are the examples of what you should enter in each case.

  • To jump to a specific range (let’s say A1:A100), enter A:A100 in the search box
  • To jump to a specific row (let’s say the second row), enter 2:2 in the search box
  • To jump to a specific column (let’s say the B column), enter B:B in the search box

You can also create a named range and then jump to that named range by typing the name in the Go To search box. For example, if you have created a defined named range with the name Data, simply enter Data in the search box and hit enter.

Using Keyboard Shortcut (F5)

The shortcut to open the Go To search box in Google Sheets is F5.

But if you use this shortcut, it will simply refresh the worksheet.

To make sure it opens the ‘Go To range’ search box, you need to first enable the compatible spreadsheets shortcuts.

Below are the steps to enable compatible shortcuts:

  1. Open the Google Sheets document
  2. Click on the Help option in the menu
    Google sheets write to cell
  3. Click on Keyboard Shortcuts
    Google sheets write to cell
  4. In the Keyboard Shortcuts dialog box, enable the ‘Enable compatible spreadsheet shortcuts’ option
    Google sheets write to cell

Now if you want to jump to a specific cell or row/column, simply hit the F5 key.

This will show the ‘Go To range’ search box, and you can enter the cell reference (range reference here)

Note: When you enable compatible spreadsheet shortcuts, you may be able to use some of the keyboard shortcuts that are also available in other popular spreadsheet tools such as MS Excel.

You can also create links to a specific cell or range (even entire row or column).

This is useful when you want to give the user the ability to click on a text string in a cell and jump to a specific cell or range. You can also use the same method to create the Table of Contents links.

Here is a step-by-step process to create a link and jump to specific cells:

  1. Select the cell where you want insert the link
  2. Right-click on the cell
  3. Click on Insert Link (you you can use the keyboard shortcut Control + K)
    Google sheets write to cell
  4. In the dialog box that opens, enter the text that you want to show in the cell
    Google sheets write to cell
  5. Click on the Link field. You will notice that it shows a few options. You can link to any sheet in the document, any named ranges, or to a specific cell/range.
  6. Click on ‘Select a range of cells to link’.
    Google sheets write to cell
  7. Enter the cell reference or the range reference.
    Google sheets write to cell
  8. Click OK.

The above steps would add the specified text in the cell you selected and when you click on it, it will jump to the cell/range you mentioned in Step 7.

The above two methods will allow you to jump to a cell or range in the same sheet.

But what if you want to jump to a specific cell/range in some other sheet.

You can do that as well (quite easily).

Suppose you have two sheets – Sheet1 and Sheet2, and you want to jump to cell A1 in Sheet2, when you’re in Sheet1.

You can create a link in a cell, and when you click on that link, it will take you to cell A1 in Sheet2.

Below are the steps to click and jump to a cell/range in another sheet in Google Sheets:

  1. Open Sheet2 (i.e, the sheet where you want to come)
  2. Select the cell/range to which you want to jump to (when you’re in Sheet1)
  3. Right-click and then click on ‘Get link to this cell/range’ option. This will copy the link to cell/range in the clipboard
  4. Go to Sheet1 and select the cell where you want to create the hyperlink. This would be the link that, when clicked, will take to cell A1 in Sheet2
  5. Right-click and the click on Insert Link (or use the keyboard shortcut Control + K)
  6. In the dialog box that opens, paste the link and enter the text that you want to appear in cell.
    Google sheets write to cell
  7. Click on Apply

That’s it!

Now when you click on the cell in Sheet1 (where you added in the link in Step 5 and 6), it will take you to cell A1 in Sheet2.

Hope you found this Google Sheets tutorial useful.

You may also like the following Google Sheets tutorials:

  • How to Indent Text in Google Sheets
  • How to Group Rows & Columns in Google Sheets
  • How to Change Row Height in Google Sheets
  • How to Insert an Image in a Cell in Google Sheets
  • How to Freeze Rows in Google Sheets

Can you add text to a cell with a formula Google Sheets?

Google Sheets Combine Text and Formula FAQ You can use the concatenate operator (&) to add text to a cell with a formula.

How do I automate text in Google Sheets?

Create a macro.
On your computer, open a spreadsheet at sheets.google.com..
At the top, click Extensions Macros. Record macro..
At the bottom, choose which type of cell reference you want your macro to use: ... .
Complete the task you want to record. ... .
Name the macro, create a custom shortcut, and click Save..

How do you make a cell say something based on another cell in Google Sheets?

Conditional Formatting Based on Another Cell Value.
Select the cell you want to format..
Click on "Format" in the navigation bar, then select "Conditional Formatting.".
Under "Format Rules," select "Custom formula is.".
Write your formula, then click "Done.".
Confirm your rule has been applied and check the cell..

How do I write under text in Google Sheets?

How to Underline Part of the Text Within a Call in Google Sheets.
Click in the cell containing the text you want to underline..
On the formula bar, highlight just the word or words that you want to be underlined..
Press Ctrl+U on Windows or Cmd+U on Mac..
The text you highlighted will become underlined..