3

I'm having a problem in Google Sheets tracking rows and columns to which a cell belongs in a large spreadsheet.

What would be really helpful and simple would be a "crosshair" function that, when active, automatically highlights the row AND column of the currently selected cell, so that when I select a cell, it looks so:

http://i.imgur.com/AL8j7Id.jpg

This would make the job of tracking cells on larger spreadsheets SO much easier. Ideally it could be set to highlight row only, column only, or both, but for my needs, I'm looking to highlight both automatically.

Is this at all possible? Is there a script to do this?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Pablo Carson
  • 342
  • 1
  • 4
  • 13

5 Answers5

2

CTRL + SPACE highlights the column
SHIFT + SPACE highlights the row

They don't work in conjunction unfortunately.

If I have time this weekend, I'll write an add-on.

caleb.breckon
  • 1,336
  • 18
  • 42
0

Well I found a way for selecting the entire row automatically. I just installed a shortcut manager to modify the keys behavior. I explained it in fully detail here: https://stackoverflow.com/a/61516763/9356315

I think you can easily extend it to select the entire column at the same time. I hope this will help.

Jason Angel
  • 2,233
  • 1
  • 14
  • 14
0

Actually working around the same issue. I've just created a script and then calling it with a macro which allows me to configure a shortcut.

function highlightCoords() {
  var ss = SpreadsheetApp.getActive();
  var s = ss.getActiveSheet();
  var a = ss.getActiveCell();

  var col = a.getColumn();
  var row = a.getRow(); 

  var r = s.getRange(row, 1, 1, col-1);
  var c = s.getRange(1, col, row-1, 1);
  var ar = s.getRange(row, col);      

  ss.getRangeList([r.getA1Notation(), c.getA1Notation(), ar.getA1Notation()]).activate();
};

Then my macro will trigger that functions.

For easy call, shortcut will be associated. Simple like: [Ctrl + Alt + Shift + 1]

Notice the active cell will be selected making F2 available for edition

Example

Market
  • 450
  • 6
  • 17
0

You can do it with a script. This article explain in details on how to highlight row, column and crosshair: https://jec.fyi/blog/highlight-apps-script

Jecfish
  • 4,026
  • 1
  • 18
  • 16
0
var userProperties = PropertiesService.getUserProperties();
var H_MODE = 'M';

function getMode() {
  return userProperties.getProperty(H_MODE);
}

function setMode(m) {
  userProperties.setProperty(H_MODE,m);
}

function createHighlightMenu() {
  setMode('off');
  SpreadsheetApp
    .getActiveSpreadsheet()
    .addMenu('Highlight', generateMenu());
}

function updateHighlightMenu() {
  SpreadsheetApp
    .getActiveSpreadsheet()
    .updateMenu('Highlight', generateMenu());
}

function generateMenu() {
  return [
    {name: (getMode()=='off'? " ✓ " :'')+'Off', functionName: 'setOff'},
    {name: (getMode()=='row'? " ✓ " :'')+' Highlight row', functionName: 'setHighlightRow'},
    {name: (getMode()=='column'? " ✓ " :'')+' Highlight column', functionName: 'setHighlightCol'},
    {name: (getMode()=='crosshair'? " ✓ " :'')+' Highlight crosshair', functionName: 'setHighlightCrosshair'}
  ];
}

function setOff() {
  setMode('off');
  updateHighlightMenu();
}

function setHighlightRow(){
  setMode('row');
  updateHighlightMenu();
}

function setHighlightCol(){
  setMode('column');
  updateHighlightMenu();
}

function setHighlightCrosshair(){
  setMode('crosshair');
  updateHighlightMenu();
}

function highlight(type) {
  const ss = SpreadsheetApp.getActive();
  const s = ss.getActiveSheet();
  const a = ss.getActiveCell();

  const col = a.getColumn();
  const row = a.getRow();
  const maxColumns = s.getMaxColumns();
  const maxRows = s.getMaxRows();

  const c = s.getRange(1, col, maxRows, 1);
  const r = s.getRange(row, 1, 1, maxColumns);
  const ar = s.getRange(row, col); 
  
  var ranges = [];
  if (type != 'column') ranges.push(r.getA1Notation());
  if (type != 'row') ranges.push(c.getA1Notation());
  ranges.push(ar.getA1Notation());
  console.log('Ranges ',ranges);
  s.getRangeList(ranges).activate();
  console.log('Active sheet ',s.getName());
  console.log('Active', s.getActiveRangeList());
}

function highlightRow() {
  highlight('row');
}

function highlightColumn() {
  highlight('column');
}

function highlightCrosshair() {
  highlight('crosshair');
};

// Uncomment this function if you need
function onSelectionChange(e) {
  console.log('onSelChange',getMode());
  highlight(getMode());
}

A small addition to https://jec.fyi/blog/highlight-apps-script code

Ravith B.
  • 11
  • 4