Color few cells in excel

Hello all,

Need to color the excel cells based on the condition

Color it in the status column condition

Cell Values
A => Yellow
B → Red
C-> Orange

Hi @Mihai_Lazer

You can use Set Range Color Activity check the below link for detail

If solution works for you please mark as solution

Thanks & Happy Automations

Use Excel activities inside Excel Application Scope for this – it’s safe and doesn’t need VBA.

Workflow Steps

Drag Excel Application Scope and set your file path.

Inside it, add Read Range (output to DT, assume Status is column index, e.g., “D”).

Use For Each Row in DT to loop rows (skip header with rowIndex = DT.Rows.IndexOf(CurrentRow) + 2 for row number).

Inside loop: If CurrentRow(“Status”).ToString = “A” then Set Range Color with Range = “D” + rowIndex.ToString, Color = New System.Drawing.Color.FromArgb(255,255,0) (Yellow).

Add Else If for “B”: Color = New System.Drawing.Color.FromArgb(255,0,0) (Red).

Else If for “C”: Color = New System.Drawing.Color.FromArgb(255,165,0) (Orange).

You can also refer to this video:

1 Like

Hi @Mihai_Lazer

Use Invoke VBA / Execute Macro to apply conditional formatting.

You can update the column Rage based on the requirement = Range(“C:C”) ’ Status column

Steps:

  1. Use Use Excel File
  2. Add Invoke VBA
  3. Paste this VBA:
Sub ColorStatus()
    Dim rng As Range
    Set rng = Range("C:C") ' Status column

    rng.FormatConditions.Delete

    With rng.FormatConditions.Add(Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""A""")
        .Interior.Color = RGB(255, 255, 0) ' Yellow
    End With

    With rng.FormatConditions.Add(Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""B""")
        .Interior.Color = RGB(255, 0, 0) ' Red
    End With

    With rng.FormatConditions.Add(Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""C""")
        .Interior.Color = RGB(255, 165, 0) ' Orange
    End With
End Sub

Another approach check out the vdieo

Regards
Gokul

1 Like

@Mihai_Lazer

If the data is being pasted to an excel which is created by automation..then using a template with Conditional formatting already configured in the template would be the easiest way..just by pasting or writing data color would auto change

if not you can use for each loop to loop on rows..then use format cells activity with if condition

cheers

Hi @Mihai_Lazer

Loop through the rows in Excel, check the status column, and use Set Cell Color to make A yellow, B red, and C orange.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.