Reputation: 13
I've a google sheets table in range A22:T2000
, with header at row 22
When it filtered (By a criteria of C column - Image),
My plan is to use OFFSET function to get the data place in a row above the table (Row 21) and set to print area (C1:H20
). OFFSET function require "Row Number". Thank you for any help.
I'm newbie in Google App Script From Excel VBA, now learning Google Sheet App Script
Upvotes: 1
Views: 437
Reputation: 64040
First Unfiltered Row
function firstrownotfiltered() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getActiveSheet();
const hr = sh.getFilter().getRange().getRow();//gets row where filter starts
const rg = sh.getRange(hr + 1, 1, sh.getLastRow() - hr);
const vs = rg.getDisplayValues();
var vrow;
for (let i = 0; i < vs.length; i++) {
if (!sh.isRowHiddenByFilter(i + hr + 1)) {
vrow = i + hr + 1;
ss.toast(`First Row Not Filtered: ${vrow}`);
return vrow;
}
}
}
Upvotes: 0