How to appy red font color data to excel data in uipath

Hi I want to apply red color to data in excel in a column ,here i dont want to apply color on the column i want to apply only on the data

@T_Y_Raju
Can you share the input and expected output

@T_Y_Raju,

Use Format Cell activity.

Thanks,
Ashok :slight_smile:

Filter Rows.xlsx (10.4 KB)
sheet 3 in input data
sheet 1 is out put data

Hi @T_Y_Raju

You can use the Format cells activity to apply the color to the specified range data in excel.
Click on set format option → Click on Fill tab → Select the color from the dropdown → Click okay

Check the below image for better understanding,
image

Hope it helps!!

Hi @T_Y_Raju

Output

Hope it helps!!

@T_Y_Raju

Sub ApplyRedColorToColumnData()
    Dim ws As Worksheet
    Dim rng As Range
    Dim cell As Range
    Dim columnNumber As Integer

    ' Set the worksheet you want to work with
    Set ws = ThisWorkbook.Sheets("Sheet1")

    ' Set the column number you want to apply the color to
    columnNumber = 1 ' Example: Column A

    ' Get the range of the column excluding the header
    Set rng = ws.Range(ws.Cells(2, columnNumber), ws.Cells(ws.Rows.Count, columnNumber).End(xlUp))

    ' Apply red color to each cell in the range
    For Each cell In rng
        If cell.Value <> "" Then
            cell.Interior.Color = RGB(255, 0, 0)
        End If
    Next cell
End Sub

Try this vb code in Invoke Vba activity hope it works for

@T_Y_Raju

Have you tried my solution

not yet iam tryinh with format cell option but iam getting error

@T_Y_Raju
Try If you get any errors let me know

Format cells is the modern excel activity you have to use inside the use excel file activity.

→ Use the Excel process scope activity → Insert use excel file activity and provide the path of the file → Inside use excel file activity insert the Format cells activity.

Then it will work, give the range like below,

Excel.sheet("Sheet name").Range("Z"+CellNo.tostring+":Z"+Lastrow.tostring)

Hope it helps!!

ok let me try and check thank you

here i see that column is getting colored in blue ,…i want only the data to be get colored with blue

will this macro will paint column or data in color

@T_Y_Raju

Have you checked with format cells activity.

@T_Y_Raju

it will colour the data only.

 columnNumber = 1 ' Example: Column A ----->in this give your column Number
And pass your sheet name

It’s always good to search the forums before posting. There are tons of posts on this already.

i see that cells are getting coloured not the data can you please check once

@T_Y_Raju

Sorry for that please check this vb code it will work for you

Sub ApplyRedColorToColumnData()
    Dim ws As Worksheet
    Dim rng As Range
    Dim cell As Range
    Dim columnNumber As Integer

    ' Set the worksheet you want to work with
    Set ws = ThisWorkbook.Sheets("Sheet1")

    ' Set the column number you want to apply the color to
    columnNumber = 1 ' Example: Column A

    ' Get the range of the column excluding the header
    Set rng = ws.Range(ws.Cells(2, columnNumber), ws.Cells(ws.Rows.Count, columnNumber).End(xlUp))

    ' Apply red color to the text in each cell in the range
    For Each cell In rng
        If cell.Value <> "" Then
            cell.Font.Color = RGB(255, 0, 0)
        End If
    Next cell
End Sub

Output: