Issue
I have a code block which will set some Value in a cell of a certain column upon a certain condition. All good there. Currently the script is set to color only that one cell. I in fact want to color fill the entire row.
Not sure how to use the declared variables in the loop to get the column range and color it.
// Iterate over every row looking for similarities from the other worksheet.
let rowsLentgh = table.getRowCount();
let rows = range.getValues();
for (let i = 0; i < rowsLentgh; i++) {
let row = rows[i];
const exhibitorName = row[companiesToCheckIndex]
const exhibitorDomainNames = row[domainNamesToCheckIndex]
const exhibitorLinkedinDomain = row[linkedinDomainsToCheckIndex]
// Look at each key provided for a matching Company Name.
for (let keyIndex = 0; keyIndex < keysObject.length; keyIndex++) {
let companyEntity = keysObject[keyIndex];
if (companyEntity.companyName === exhibitorName) {
overallMatch = true
range.getCell(i, screeningColumnIndex).setValue("Matched");
range.getCell(i, screeningColumnIndex).getFormat().getFill().setColor("FF0000");
range.getCell(i, screeningColumnIndex).getFormat().getFont().setColor("000000");
break;
}
Solution
Change the code lines
range.getCell(i, screeningColumnIndex).getFormat().getFill().setColor("FF0000");
range.getCell(i, screeningColumnIndex).getFormat().getFont().setColor("000000");
If range
is the data body range of table, it doesn't include the header row. i+1
is needed in the first snipppet.
table.getRange().getRow(i+1).getFormat().getFill().setColor("FF0000");
table.getRange().getRow(i+1).getFormat().getFont().setColor("000000");
OR
range.getRow(i).getFormat().getFill().setColor("FF0000");
range.getRow(i).getFormat().getFont().setColor("000000");
Answered By - taller
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.