I am trying to count comments or specific words written by users in Google Sheet table. for example 5 accounts have permission on sheet and i want to count how many comments or yes/no is written in table by each user. is there any solution for this task?
Asked
Active
Viewed 262 times
0
-
I don't think you can access comments via the API [see this](https://stackoverflow.com/questions/32359481/how-to-get-a-note-or-comment/32444081#32444081). – Cooper Jul 21 '17 at 15:01
-
Are the yes/no responses accessible with range.getValues and are they the only text within those cells? – Cooper Jul 21 '17 at 15:04
-
yes/no are only text – SunCode Jul 21 '17 at 15:18
1 Answers
1
This will get the yes/no count case insensitive and it also has two arrays (yays and nays) which contain the row and column of each yes/no response. Also gets the Users email address.
function getYesAndNo()
{
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sht=ss.getActiveSheet();
var rng=sht.getDataRange();
var rngA=rng.getValues();
var yays=[];
var nays=[];
var yay=/yes/i;
var nay=/no/i;
var user = Session.getActiveUser().getEmail();
for(var i=0;i<rngA.length;i++)
{
for(var j=0;j<rngA[i].length;j++)
{
if(String(rngA[i][j]).match(yay))
{
yays.push([Number(i+1),Number(j+1)]); //rows and columns not indexes
}
if(String(rngA[i][j]).match(nay))
{
nays.push([Number(i+1),Number(j+1)]); //rows and columns not indexes
}
}
}
Logger.log(yays);
Logger.log(nays);
SpreadsheetApp.getUi().alert('User Email = ' + user + ' Yes Count = ' + yays.length + ' No Count = ' + nays.length);
}

Cooper
- 59,616
- 6
- 23
- 54