
Announcements
Hi!
I need to run a flow in Power Automate that generates a new Excel file with some data. In this Excel sheet, I would like to control that if a value is, for example, below 100, the text should be colored red. Is there any way to control this in Power Automate?
Thank you in advance for your help!
function main(workbook: ExcelScript.Workbook) {
let sheet = workbook.getActiveWorksheet();
let range = sheet.getRange("A:A"); // Select the entire column A
let values = range.getValues(); // Get all values in column A
// Loop through each row in column A
for (let i = 0; i < values.length; i++) {
let cellValue = values[i][0]; // Get the value of the current cell
let cell = range.getCell(i, 0); // Get the cell reference
if (typeof cellValue === "number" && cellValue < 100) {
cell.getFormat().getFill().setColor("red"); // Set background color to red
} else {
cell.getFormat().getFill().clear(); // Clear formatting for other cells
}
}
}
------------------------------------------------
⭐ If this was helpful, please like and check the box below "Does this answer your question" to help others find this too!
Always glad to help! 💯💯💯💯💯
Tom
Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn