ROW_VALUES Function for Google Sheets

The custom function ROW_VALUES for Google Sheets returns the non-empty values of a range of cells as an array, in a row format.

Simply copy and paste the code of the ROW_VALUES function into the script editor to be able to use it later (for more details, check out the Add a Custom Function to Google Sheets page).

Usage Example

The ROW_VALUES function lists here the data from the non-empty cells of the range B1:F3:



google sheets function row values

Google Apps Script Code of the Function

The code of the function to copy-paste into the script editor:

function ROW_VALUES(values) {
  // Source:
  // Range on one column
  let array = values.flat();
  // Removal of empty values
  array = array.filter(x => x != '');
  // Returns the array
  return array.length ? [array] : '';