title: Google Sheets - Track Current Cell Selection?
body: <p><a href="https://stackoverflow.com/questions/30779426/">How to Get the currently selected cell/range?</a>  was asked 3.5 years ago, but I'm hoping maybe some progress was made since then.</p>
  
  <p>I'd like to make an interactive spreadsheet where there's a boolean grid that will display more information about the status of the currently selected cell in a static location, allowing users to quickly navigate using the arrow keys. </p>
  
  <p>Referencing the previous instance of this question, I tried using the custom function below to get the cell address, although this isn't very dynamic.</p>
  
  <pre><code>function currentCell() {
    return SpreadsheetApp.getActive().getActiveRange().getA1Notation();
  }
  </code></pre>
  
  <p>When testing, this function returns the address of the cell the function is called from. I've tried pressing F5 while highlighting another cell and nothing happened. I've also dragged the formula across a selection and each cell only contains its own address (according to the documentation, it should contain the range).</p>
  
  <p>I've also read <a href="https://stackoverflow.com/questions/9022984/script-to-summarise-data-not-updating/9023954#9023954">Henrique's post on caching</a> from 2012, and while I don't completely understand it, I get that we could not get scripts which update without edits being made or manual formula updates. </p>
  
  <p>I would ideally like for the current cell to be tracked without any extra prompts from the user besides arrow key navigation or clicking to select a cell, but if pressing a non-altering key (like Enter) would allow for tracking, that would be fine. I also only need the selected cell, rather than a range, if that makes things easier.  </p>
  
  <p><strong>Explicit Question:</strong> Is it possible to track the position of the currently selected cell in Google Sheets and store that position in a separate cell? If not, is there a way to do this without altering cell values? </p>
  
  <p>EDIT: Adding an example for clarity. In this conceptual example, A2 <code>=currentCell()</code> as described above. If I were to hit the right arrow key, A2 would update to display <code>I4</code>, since it is now the current selection.
  <a href="https://i.stack.imgur.com/czNjw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/czNjw.png" alt="Current selection position stored in A2."></a></p>
  
  <p>EDIT2: <a href="https://stackoverflow.com/questions/47919639/google-app-script-monitor-spreadsheet-selected-ranges">Jason Allshorn's response to Google app script monitor spreadsheet selected ranges</a> appears to give a way of displaying the current selection (range) on the HTML input text. I'd like to do this, but store the value in a static cell on the sheet rather than input text. I'm new to scripting in Sheets and really only know what I've found for resolving this issue, so if I'm overlooking something, please let me know. I did look at Jason's example sheet and it wasn't clear to me what was actually happening there. </p>