The closest thing you can have is the following script.
Code
function onOpen() {
SpreadsheetApp.getUi().createMenu("Harmonize")
.addItem("Go !!", "mySheets").addToUi();
}
function mySheets() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
// retrieve number of sheets
var nshs = ss.getNumSheets();
// find first sheet
for(var i=0; i<nshs; i++) {
var sh = ss.getSheets()[i];
if(sh.getIndex() == 1) {
var aCell = ss.getActiveCell().getA1Notation();
var index = i;
}
}
// set active range throughout the sheets
for(var j=0; j<nshs; j++) {
if(ss.getSheets()[j].getIndex() != 1) {
ss.getSheets()[j].setActiveSelection(aCell).activate();
Utilities.sleep(200);
}
}
// return to first sheet
ss.getSheets()[index].setActiveSelection(aCell).activate();
}
Explained
Upon opening, a menu item is created. Selecting this item, will execute the mySheet
function. This will find the first sheet (doesn't need to be getSheets[0]
) and its index
plus the A1Notation()
. After that, it will set the active selection of each sheet according to the first sheet.
Example
I've created an example sheet for you: Set Selection throughout all sheets
Short answer
=ArrayFormula(vlookup(ROW(1:10),{IF(LEN(A1:A10)>0,ROW(1:10),""),A1:A10},2))
Explanation
Assuming the input data in the Column A
of the below table and that the above formula is in cell B1
.
Note: In order to make easier to evaluate the formula, the Column A
(input) doesn't repeat values but it will work with any kind of values (letters, numbers, symbols, repeated, unsorted, etc.)
| A B
=== + ======= =======
1 | a a
2 | a
3 | b b
4 | b
5 | b
6 | c c
7 | d d
8 | e e
9 | e
10 | f f
VLOOKUP
was selected as it could be used to find approximate values and it could return multiple values (array).
As the input values could appear in any order, instead of using the actual values, the row number was used for non empty cells and empty cells have assigned an empty string ""
.
It was used LEN
instead of ISBLANK
because cells with formulas that return an empty string return FALSE
and this could cause problems in some common scenarios.
IF(LEN(A1:A10)>0,ROW(1:10),"")
NOTE: In you want to save three characters, the second parameter (""
the character is the parameter separator ,
) could be removed. When analysing this part of formula empty cells will return FALSE
.
As VLOOKUP
requires that the lookup up column be the first column, instead of a range, a "semi-manually" made array was used.
{IF(LEN(A1:A10)>0,ROW(1:10),""),A1:A10}
The above approach save us cells and processing time.
Best Answer
With the code below you can have a fairly responsive interaction with the user.
Code
Example
I've created an example file for you: Copy of Reading scheduler. See also revised code for removing data.