TABLE Function for Google Sheets

The custom TABLE function for Google Sheets returns an HTML formatted table based on a range of cells (or a similar array).

Simply copy and paste the code of the TABLE 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

Here, the TABLE function returns the values of the range A1:B11 in the form of an HTML table:



google sheets function html table

Google Apps Script Code of the Function

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

function TABLE(range) {
  // Source:
  return '<table>' + => '<tr><td>' + r.join('</td><td>') + '</td></tr>').join('') + '</table>';