How to Highlight Active Row in Google Sheets (2 Suitable Ways)

Sometimes working on a spreadsheet, you may need to highlight the active row or the active column. It will help you to enter data in the correct row even if you are far away from the first column. You can also easily find data in the same row without mistakenly jumping to another row. In this article, we will demonstrate how to highlight the active row in Google Sheets.


A Sample of Practice Spreadsheet

You can get the practice sheet from here.


2 Suitable Ways to Highlight Active Row in Google Sheets

The dataset below contains Student’s Name and Marks. We will use the dataset to illustrate 2 alternative ways to highlight the active row in Google Sheets. Let’s begin!

how to highlight active row in google sheets


1. Use Keyboard Shortcut to Highlight Active Row

Here, we will use a keyboard shortcut to highlight the active row using that dataset. Follow the steps below to do that.

📌 Steps:

  • First, select a random cell, for example, select cell B7.

Use Keyboard Shortcut to Highlight Active Row in google sheets

  • Then select SHIFT + Spacebar or CTRL + SHIFT + ➔ to highlight the last cell before a blank cell in the active row.

  • Now hold the SHIFT key and press the Spacebar again to highlight the entire row as follows.

Read More: How to Highlight Highest Value in Row in Google Sheets (2 Ways)


Similar Readings


2. Highlight Active Row Using Apps Script in Google Sheets

You need to use the keyboard shortcut again and again whenever you select a new cell. To make this a seamless process, here we will use Apps Script to highlight the active row. Follow the steps below to be able to do that.

📌 Steps:

  • First, select Extensions from the menu bar and choose Apps script from the drop down list.

Highlight Active Row Using Apps Script in Google Sheets

  • Then, the Apps Script window will open in a new tab.
  • Now copy the following code using the copy button.
function onSelectionChange()
{
var range = SpreadsheetApp.getActiveRange();
var sheet = range.getSheet();
var rows = sheet.getMaxRows();
var columns = sheet.getMaxColumns();
sheet.getRange(1,1,rows,columns).setBackground(null);
sheet.getRange(range.getRow(),1,range.getNumRows(),columns).setBackground("yellow");
}
  • Then paste the copied code into the Apps Script window, click on the Save icon and then run the code using the Run button.

  • Now authorize Google Sheets to run the code and return to the spreadsheet. Then select any cell or range to see the active row getting highlighted as follows.

  • You can also select multiple cells at a time. Then all the corresponding rows will be highlighted too.

Explanation of Apps Script Code

function onSelectionChange()
The code runs when you select another cell or range.

var range = SpreadsheetApp.getActiveRange();
This variable stores the active range.

var sheet = range.getSheet();
The name of the active sheet is stored by this variable.

var rows = sheet.getMaxRows();
This code line counts the maximum number of rows in the active sheet.

var columns = sheet.getMaxColumns();
This code line counts the maximum number of columns in the active sheet.

sheet.getRange(1,1,rows,columns).setBackground(null);
Removes the background fill color from the entire sheet.

sheet.getRange(range.getRow(),1,range.getNumRows(),columns).setBackground("yellow");
Sets Yellow as the fill color of the entire active row.

Read More: How to Highlight a Row in Google Sheets (3 Quick Methods)


Things to Remember

  • Always validate the authorization while running the code on Apps Script.
  • You can use the right arrow key or the left arrow key while using the keyboard shortcut.

Conclusion

In this article, we demonstrated how to highlight the active row in google sheets using Apps Script and keyboard shortcut. Hopefully, the methods will help you to apply these features to your own dataset. Please let us know in the comment section if you have any further queries or suggestions. You may also visit our OfficeWheel blog to explore more Google Sheets-related articles.


Related Articles

Afrina

Afrina

This is Afrina Nafisa. Currently working as a Technical Writer at OFFICEWHEEL.COM. I have done my graduation from Ahsanullah University of Science and Technology. As I am eager to learn more and more currently my motive is to make myself better every day with my work so that I can make better content for all the readers.

We will be happy to hear your thoughts

Leave a reply

OfficeWheel
Logo