This was done using UiPath.Excel.Activities 2.16.2 - it may work with older versions, I don’t know when these activities were introduced. It likely works with newer versions also.
This particular code I’m showing sets negative numbers to red, but you could of course also put a Format Cells activity into the Then block to format positive numbers green, for example.
Basic steps:
Excel Process Scope
- Use Excel File
– For Each Excel Row
— If to determine positive or negative
---- Format Cells activity. Source is defined like this: Excel.Sheet(“Sheet1”).Range(CurrentRow.ByField(“ENDING BALANCE (DECISION DATE)”).Address)
The real key is that last expression:
CurrentRow.ByField(columnName).Address
…which gives you the cell range (ie L5, L17, etc)
And, of course, I clicked Set Format and selected red for the font color:
Result: