How to set colour for excel header

Hi Uipath folks,
Is there any way to set color for header of an excel sheet ? If yes, can you guide me please ? :slight_smile:

Hi @simadri

below activity will help you,


1 Like

Hi @simadri

I hope this video might be helpfull to you .How to set colour for excel header

cheers :smiley:

Happy learning :smiley:


I couldn’t find this activity…

Is there any alternate for this activity.

This is the package version I’m using

Hi @rnahasnahasuddin

Use can use the below Macros Code:

Sub ColorHeaders()
    Dim ws As Worksheet
    Dim headerRange As Range
    Dim lastColumn As Long
    Dim headerCell As Range
    ' Set the worksheet where you want to colorize the headers
    Set ws = ThisWorkbook.Sheets("Sheet1") ' Replace "Sheet1" with your sheet name
    ' Find the last column with data in the first row
    lastColumn = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
    ' Define the range containing the headers (limited to where the data is present)
    Set headerRange = ws.Range(ws.Cells(1, 1), ws.Cells(1, lastColumn))
    ' Loop through each header cell in the range
    For Each headerCell In headerRange
        ' Set the color for the header cells
        headerCell.Interior.Color = RGB(255, 255, 0) ' Set color to yellow (RGB(255, 255, 0))
    Next headerCell
End Sub

Save the above code in a Notepad file. you can try to replicate the below image process. Change the excel file path and Sheet name according to yours.

SetColor.txt (848 Bytes)