Set range color activity takes a lot of time

Hi,
I want to paint positive and negative number in Difference column. But it takes six hours( excel have 140.000 rows). What other way can i do this?


Hi @murat.karasoy ,

You can give the following VBA a try:

Sub SetColor()
Dim xlRange As Range
Set xlRange = Range("J:J")
    For Each c In xlRange
    If IsNumeric(c.Value) Then
        If c.Value < 0 Then c.Interior.Color = vbRed
        If c.Value > 0 Then c.Interior.Color = vbGreen
    End If
    Next c
End Sub
1 Like

@murat.karasoy

You can actually use a conditional formatting option on the excel itself to automatically change the color of cells…you need not use UiPath

You can have a template already created with formatting and then paste the data onto that template…then it will automatically change

Cheers

HI,

Can you try use AppendItemToList (or some activity to add item to list) to create list of range string inside ForEachRow, then use SetRangeColor with concatenate list string after ForEachRow, as the following?

The following is a mock sample.

Sample20230402-1L.zip (3.1 KB)

Or if the ForEachRow is also slow, the following LINQ might help you.

listRange = MainDataTable.AsEnumerable.Where(Function(r) convert.ToDouble(r("Difference"))<0).Select(Function(r) "J"+MainDataTable.Rows.IndexOf(r).ToString).ToList

Regards,

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