How to set colour in particular cell in Excel

Hi al,
I am facing a scenario that I should set a colour in a particular cell range in excel . for example yes for green colour and no for red colour.

2 Likes

@mohan2,

Read the cell value and check if it is green or red.

Then use Set Range Color activity to set the color.

1 Like

Hi @mohan2

Read each cell value and check with if condition and then use Set Range Color activity.

Set Range Color activity to set a color for a range(β€œA1:A2”) or a cell(β€œA1”).

To Set Green color use System.Drawing.Color.Green in Color and To Set Red color use System.Drawing.Color.Red in color input.

Regards,
Vijay Kumar C.

3 Likes

@mohan2

Use Set Range Color activity to set color for particular cell or given range.

3 Likes

in set range colour activity , what range we will give.

1 Like

Give the index of the cell.
ex: β€œA6”,β€œA1:A5”

@mohan2

You can give the range value like β€œA1”, β€œB6” for single cell and β€œA1:B6” for multiple cells.

@mohan2,

Read Index of that row also at the time of reading cell value.

If it is β€˜B’ Column then specify set range as: β€œB”+index.toString

1 Like

I don’t know that in which index the data will be there in excel, so it will be in dynamically. so I cant set the particular range value. becaz the yes or no will be in the random place in excel.

@mohan2,

Could you please send me sample excel file.

colour test.xlsx (7.8 KB)

@mohan2,

Is there any headers for this excel file or not ?

1 Like

there is no header , but in that excel there is yes and no data, so I need colour for yes is green and no is red.

@mohan2

Is column number fixed for values Yes and No Like Always be 4th column ?

1 Like

no the column number is not fixed , yes or no will anywhere in that excel. according that colour should set in the cell.

@mohan2,

Please find the attached file.
colorTest.zip (9.2 KB)

2 Likes

Thank you very much for your quick and good response.
It works. Then after all, column number should be converted to alphabet using sort of conversion data table -build data. I wondered if any way to refer cell range of A1, B1, C1, so on … with variable for A/B/C… if not, then need to convert number to alphabet as your solution. Or, checking a bit further how to convert number to alphabet including AA, AB, AC… 2 characters of columne names.
Thanks for your time and advice.

2 Likes

Hey Mohan,

I created this demo as per your question, please check this:

2 Likes

Mohan, this would get what you are trying to accomplish:

1 Like