Instead of filter views, I would use the filter
command. For example, suppose Sheet1 holds raw data, with A being a character, B the list of "mentioned" chapters, and C the list of "appeared" chapters. You can then add another sheet for "filtered" data, where the user enters chapter number in, e.g., cell A1 and immediately get the list of rows matching that number thanks to the command
=filter(Sheet1!A2:C, regexmatch(Sheet1!B2:B,"\b"&A1&"\b") + regexmatch(Sheet1!C2:C,"\b"&A1&"\b"))
Here, each regexmatch
scans its column (B or C) paying attention to word boundaries (\b
) so that, e.g., "20,23,25" would not match "3". Addition plays the role of OR operator here.
If you are sharing this, you can allow editing but protect all cells except A1 on the second sheet: this way, the users can only change the chapter number for filtering.
There is a potential drawback: the changes to A1 are actual edits; i.e., what one user does affects everyone. If this is unacceptable, then filter views are the only option. You can circumvent the "OR" issue by creating a new column with
=B2&","C2
i.e., concatenation of columns B and C. Then apply filter views based on that column. However, the filter view will require either
- custom formula with regexmatch as above (not user-friendly at all)
- different format of data to make the condition "text contains..." work: for example, you could format as
,2,4,10,13,16,
so that the text to search for would be ,4,
(Otherwise, there's the same issue of "13" matching "3".)
In short, you cannot access myAddOnFunction()
programmatically.
However, what you could try is simply inserting the necessary text into your target cell. For example:
var cell = yourRange.getCell(1, 17);
cell.setValue('=myAddOnFunction(yourParameters)');
If the add-on is designed to execute functions when present in cells, inputting that string into a cell would trigger the add-on.
Best Answer
One can concatenate the content of text columns without a script, using
=arrayformula(D:D & E:E)
in another column. But apparently you want D and E to just be replaced by a single column that has concatenated values. This can be done with a script like this:The main step is
which loops over the rows in D:E, joining the content of cells. The empty string
""
in between is to ensure we get string concatenation and not addition; so, 3 and 6 become 36 rather than 9.The script deletes column E since it is presumably no longer needed.