You can get the filtered range dimensions from getFilter().getRange()
. This will copy all the filtered range:
function copycolA() {
var sourceSheet = SpreadsheetApp.getActive().getSheetByName('Current');
var targetSheet = SpreadsheetApp.getActive().getSheetByName('A');
var sourceRange = sourceSheet.getFilter().getRange();
sourceRange.copyTo(
targetSheet.getRange('A1'),
SpreadsheetApp.CopyPasteType.PASTE_NORMAL,
false);
}
To read:
- Filter#Range
- Related answer
Note that .getValues()
or other script operations will NOT get the filtered only, but all of the values.