GAS – Get Array from Data Validated Range

Been happily grabbing data ranges from cell ranges in google sheets for ages, but never spotted that if you have a range where all the cells have data validation in them (e.g. a list of values or list from range), then even if they are blank, e.g. no selection has been made, GAS still counts them if you get the “length” of the array. This little snippet deals with that!

One thought on “GAS – Get Array from Data Validated Range

  1. Found a couple of other ways – inline

    var myarray = SpreadsheetApp.getActive().getRange(“A1:A10”).getValues().filter(String);


    var myarray = SpreadsheetApp.getActive().getRange(“A1:A10″).getValues().filter(Boolean);

    or possibly both?



    which gives


Leave a Reply to Metricrat Cancel reply

Your email address will not be published. Required fields are marked *