How to change the font color in the excel cell

Hello fellows,

@supermanPunch @AndersJensen @NIVED_NAMBIAR

Here I want to change the cell font color black to red.

Here is the workflow

image

I’m writing “C” in the excel cell. I want to write it in the Red color on the excel sheet

How can we do this?

Thanks in advanced

1 Like

Hi @Vrushali_Gave ,

Please refer below article it night help you

Thanks!

1 Like

@1996 Thank you for your response

But the excel running in background and it has 100+ “Not match” rows so this solution will not work for me

@Vrushali_Gave You can use the Set Range Color Activity in Excel.Activities

1 Like

Easiest thing will be to do a vba script and then run it with Uipath

@AndersJensen Yes right. I have tried with the below code :slight_smile:

Range(“A1”).Font.Color = vbRed

But I’m getting an error :

Error Validation Error No compiled code to run
error BC30512: Option Strict On disallows implicit conversions from ‘String’ to ‘Integer’. At line 1
error BC30451: ‘vbRed’ is not declared. It may be inaccessible due to its protection level. At line 1 Comparing.XAML

@supermanPunch I want to change font color

1 Like

@Vrushali_Gave …Try UiAutomation using SendHotkeys

Hello,

How can we do this?
Any solution?

@Vrushali_Gave Can you check this Example Workflow :
Excel_Automation.zip (16.1 KB)
It is a bit lengthy and the operations can be minimised to be used in Excel Application Scope itself, But I have made use of in memory operations such as Datatable operations more, just to make sure I perform only one Kind of operation in the Excel Application Scope.

(Note : If you have the Column Name already known and is not dynamic you can remove the Number to Letter workflow to get the Column Name in the Excel and replace with the Constant Column Name)

Let me know if this isn’t the kind of output that you were expecting or if it didn’t work at all.

@supermanPunch Yes sir, It’s a lengthy process. is there any other way?

@Vrushali_Gave Are you updating the Column Directly without any condition or is there a validation in place before updating ,Also is the Column to be updated already known or is it dynamic. If it is already known, you can assign the column name directly and remove the Number to Letter workflow.

Also let us know from your perspective as to why you think this is a lengthy process.

@supermanPunch Yes sir, the Column name is dynamic. I have tried your code but I’m getting an error for the VBA activity

image

@Vrushali_Gave Are you able to execute the Macro Manually by replacing the columnIndex with a cell number like “A1” ?

Also can you post the Screenshot of the Complete error ?

@supermanPunch No, I’m not aware about Macro. Sir is there any simple way to change text font color?

@Vrushali_Gave If you are allowed to change the Excel Settings, Can you Perform this Change and then check if the workflow works.
Go to Excel - > Options → Trust Center → Trust Center Settings → Macro Settings → Enable All Macros.

Click on Ok.

Let us know if you are not able to do this or if you still receive the same error even after the change.

@supermanPunch Yes, I have changed the setting. No error occurred but the font color has not changed.

I have attached the workflow
Main.xaml (12.7 KB)

Excel o/p:
image

@Vrushali_Gave What value are you passing to the columnName variable in Invoke VBA ?

I guess it is Empty, Can you check on that and revert back ?

@supermanPunch Yes right, I have modified it.

image

But same output as previous.

colIndex is today date and that is the column name

@Vrushali_Gave colIndex refers to the Index of the Column and not the column name, According to the Workflow that you have provided you need to use Now.ToString(“dd”) as the column name for identification of the column to be updated in the DT.
But to Change the Color of the Updated value in the Excel you would need to have the column names of the Excel i.e A, B, C, …

I have recognised that you have not used the Number To Letter workflow for retrieving the Column Name of the excel dynamically, but it is very much needed if the Column name is not known.

Note that, The Column Names of the Datatable are different and the Column Name that we need to identify for Changing the Font Color is different.

Can you just execute the below workflow and let me know if it worked. The Test Excel file should have the values under the Column “Update” in red color after the execution.

Excel_Automation.zip (16.5 KB)

Then accordingly, you could use your Input file and Column Name, by only changing the values present in the First two Assign Activities and then Execute for your Inputs.

Let us know if you are still facing issues.