function ClearCells()
{
var sheetName = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
var topCell = sheet.getRange('G36');
var numValues = topCell.getValue();
var columnVal = topCell.getColumn();
var rowVal = topCell.getRow();
for (var i = 1; i <= numValues; i++)
{
var cell = sheet.getRange((rowVal + i), columnVal);
var cellValue = cell.getValue();
Logger.log("Clearing cells - " + cellValue);
sheet.getRange(cellValue).clearContent();
}
}
For the numValues, in that cell use put =COUNTA([cell column]:[cell row + number of values that might be below])