M
M
meexss2020-05-31 15:10:37
Google Apps Script
meexss, 2020-05-31 15:10:37

How to highlight active cell row in google sheet?

Work is being done in large tables and it is not convenient to substitute the ruler to the screen to see what the active cell belongs to. I tried using conditional formatting as it was done in EXCEL, but it does not work, the macro from EXCEL cannot be transferred either. I'm at a dead end!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Stoyanov, 2020-06-03
@meexss

You can try this function:
But it overwrites the background of the cells and does not work instantly.

function onSelectionChange ( e ) {
  let cache = CacheService.getDocumentCache();
  let range = e.range;
  
  let oldRow = cache.get("oldRow");
  if ( oldRow > 0 ) {
    e.source.getRange(oldRow+":"+oldRow).setBackground("#fff");
  }
  
  if ( range.getNumRows() === 1 ) {
    let row = range.getRow();
    
    e.source.getRange(row+":"+row).setBackground("#f3f3f3");
    
    cache.put("oldRow", row);
  }
}

Or like this:
function onSelectionChange ( e ) {
  let range = e.range;
  
  e.source.getRange("A:A").setValue("");
  
  if ( range.getNumRows() === 1 ) {
    let row = range.getRow();
    
    e.source.getRange("A"+row).setValue("SELECTED");
  }
}

I. set up conditional formatting: But the best option, in my opinion, is to write a script for your browser that would work on top of the page with the table. For example, through the tampermonkey extension . --- Maxim Stoyanov (stomaks), developer of Google Apps Script . g-apps-script.com stomaks.me
=IF($A1 = "SELECTED"; TRUE; FALSE)

P
Pepic Papilazio, 2020-06-02
@papilaz

If you use conditional formatting, it's easy. We set up for the first column so when we set 0 in the first column, the color of the line turns on, telling us about editing it. When we finish exercising with this line, we simply put one - the work is finished, and the line is marked with a different color. Even so))

M
meexss, 2020-06-18
@meexss

I found how I wanted it to look. ( https://jsfiddle.net/x6c0bx4f/)
But does anyone know how to do the same in Google Sheets? (maybe a macro?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question