[SOLVED] How can I link cell values to match in Google Sheets?


This Content is from Stack Overflow. Question asked by Nick W

I have a Google Sheet with data from companies financial statements in them. I have both quarterly and annual data for them, and so I have a drop down cell at the top of my sheet with a selection of “Annual” and “Quarterly” where the data will then change based on the cell value. I have data for all three statements and ratios which is 150 rows long so it can be aggravating to scroll to the top each time just to change the increment and then scroll back down.

I was looking for idea’s from anyone more familiar with Google Apps Script that might know about how I can link four cell values so I only need to change one and all four will change. I would like a drop down in each section but I can still change anyone of them and they all correspond.

Thanks for the help.


Change one and all the others will change

function onEdit(e) {
  const sh = e.range.getSheet();
  const loc = e.range.getA1Notation();
  const all = ["A5","A10","A15","A20"];//you can edit and add locations
  const idx = all.indexOf(loc);
  if(sh.getName() == 'Your Sheet Name' && ~idx && e.value ) {
    let oneless = all.slice();
    oneless.forEach(l => {

This Question was asked in StackOverflow by Nick W and Answered by Cooper It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?