How to fill colour to cell in excel

Hi all,
How to add color to specific cell in excel file, please guide me on this.
test.xlsx (8.9 KB)
Sample file added please check
Sheet1 input file
Sheet2 output file.
Please guide me on this.

Hi @lakshmi.mp

Use can use VBA Macros to do this. Below is the Macro code:

Sub ColorNonNumericCells()
    Dim ws As Worksheet
    Dim rng As Range
    Dim cell As Range
    
    ' Define the worksheet and range to check
    Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet name
    Set rng = ws.UsedRange ' Change this to the specific range you want to check
    
    ' Loop through each cell in the range
    For Each cell In rng
        ' Check if the cell contains a non-numeric value
        If Not IsNumeric(cell.Value) And Not IsEmpty(cell.Value) Then
            ' Color the cell if it's not numeric
            cell.Interior.Color = RGB(0, 255, 0) ' Red color
        End If
    Next cell
End Sub

Text File
ColorSpecific Cell.txt (670 Bytes)

Output:

Hope it helps!!

@Parvathy , can we fill cell using write cell activity.
In actual file the headers are different.

Hi @lakshmi.mp ,

After reviewing your use case, I created a workflow and successfully implemented it.

So let me explain you about the approach

  1. Read sheet1 into dt
  2. write dt with “Exclude headers property” ticked into Sheet2
    3.Use Linq to get all the celladdress of the cells containing alphabets into a list
  3. Use a for Loop over the cellAddress List and
    • Use format Cell Activity to Fill the Colour

Below is the Worflow for your reference
colourCell_In_Excel.zip (10.4 KB)

Hope it helps you out!

Hi @lakshmi.mp

You can’t use Write Cell to Fill colors. How will be the columns names in the original files?

Regards

test.xlsx (8.9 KB)
These are the headers and expected output @Parvathy please look into it

Hi @lakshmi.mp

The above code will work at any case. Please check the below output:

Output:

Regards

@Parvathy , in actual file there is no numeric values in headers, I have added. In that case what to do.

What will be there instead of Numeric @lakshmi.mp

Regards

@Parvathy ,
image
Like this 37 fields are there. Please check the screenshot…

Hi @lakshmi.mp

Do you want to that five column names to be filled with colors.

Regards

ya, which are highlighted with green in sample file need to be filled @Parvathy

Hi @lakshmi.mp

Check the below text file and check

ColorSpecific Cell.txt (983 Bytes)

Regards

2 Likes

Hi @lakshmi.mp ,

Have you tried the approach

given in the above thread?

Let me know if changes has to be made

@Parvathy , what should be the argument
image


Please check the below screenshot, the changes done are correct?

Hi @lakshmi.mp

You need not add any arguments. If you want to make the code dynamic then you add arguments.

Regards

@Parvathy , thanks a lot able to work on this… Thank you for your support

1 Like

You’re welcome @lakshmi.mp

I’m happy to assist you.

Happy Automation

1 Like

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