Skip to content

Instantly share code, notes, and snippets.

@rheajt
Created August 28, 2017 00:11
Show Gist options
  • Save rheajt/8ce2f2f8890fd4b2b837325f0aa040b8 to your computer and use it in GitHub Desktop.
Save rheajt/8ce2f2f8890fd4b2b837325f0aa040b8 to your computer and use it in GitHub Desktop.
call columns by their headers
function callColumnsByHeaders() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var rg=sh.getDataRange();
var vA=rg.getValues();
var hA=vA[0]; //header row
for(var i=1;i<vA.length;i++)
{
var row=[];
for(var j=0;j<vA[0].length;j++)
{
row[hA[j]]=vA[i][j];
}
Logger.log('Email:%s Subject: %s Message: %s',row.Email,row.Subject,row.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment