I can't believe this hasn't been brought up, but I've looked at about 30 questions and none mention this specific scenario.
The Backstory
There is a data set on a web page that grows over time. I am attempting to maintain a persistent copy of this data in a sheet where the user can add information in additional columns. I have a script that the user runs in the browser console to scrape the entirety of the data set. (I do the entire set every time because it makes the process uniform for new and repeat users, and because I have no way to incorporate the existing data to act as a stop point/filter) This scraped data is then pasted into an input area of my spreadsheet to be processed by an App Script.
The import process is intended to filter out the existing data from the input, and append the new unique data to the end of the existing data. This allows the additional info added by the user to remain undisturbed.
My Approach
I'm trying to minimize the amount of script work on this sheet, and am relying on formulas to do as much heavy lifting as possible. To that end I have settled on the FILTER() formula for removing the duplicate data from the input. I hate it, but I haven't found another solution that works as well.
There is an intermediary area of the sheet that holds the output of this formula. So user pastes data in to an input range > the FILTER() formula builds the range of new data on the fly > script is meant to copy this data to the end of the existing data.
The Problem
In the UI the Ctrl + Down shortcut works as expected, and will move the cursor to the end of the data in the FILTER() output. When recording a macro it creates a script with the getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
call as I would expect. The issue is that executing this script results in the cursor moving all the way to the end of where the FILTER() formula extends its influence.
The phantom data is only detectable by the scripts. I can copy paste blank rows from this range and they act as blank in the destination for all user input, but scripts will detect the phantom data in the new location as well. As the title suggests, this applies to the UNIQUE() formula as well, and I would assume QUERY and any other formulas that generate a range of data from a single cell.
I could just accept that these cells exist, let them get copied all over, and then sort my various ranges to get all the data together, but this poses another problem. The copying of all these blank rows results in a rapid increase in rows in my sheet. And with all the copying happening the blank cells will be compounded in some ranges, leading into tens of thousands of new rows being added to a sheet within a few imports.
The Real Question
Is there a way to make getNextDataCell() ignore blank rows from formulas like FILTER and QUERY?
Edit Note: I've removed the secondary questions to focus solely on making App Script ignore blank cells because apparently people think this is too broad as written.