How to change particular cell values in excel


in an excel file there are two keys. Some combinaitons are allowed others not. In the first step I filtered the file so I get only the combinations that aren’t allowed - that works fine. Now I want to change the keys, so the combinations are allowed.


In the following I want to change the combination Key 1: S and Key 2: B. So if Key 1 is S AND Key 2 is B then I want to change Key 1 to “SA”.
I used the “For Each Row” Activity and the following If-Condition: row(“Key 1”).ToString.Equals(“S”) And row(“Key 2”).ToString.Equals(“B”).
In the THEN-Condition I used a Assign-Activity. I think that’s where my program doesn’t work anymore.
I used the following: row.Item(“Key 1”) = row.Item(“Key 1”).ToString.Replace(“S”, “SA”).

Can someone help me? I am very grateful for every tip!

Best regards

@cathschaen Since your using if condition use below assign activity in else part or then part.

row(“columnName”)=“your value”

1 Like

@Manjuts90 thanks for the tip, but that doesn’t solved my Problem. I enclosed my program. Maybe you can have a look ? :slight_smile:

@cathschaen Can you share sample excel file?

@cathschaen In your workflow your updating values to datatable, but not writing again back to excel file and also in if condition use trim method like below. It will be useful if values contains space before or after the string from next time onwards.

row(“Key 1”).ToString.Trim.Equals(“S”) And row(“Key 2”).ToString.Trim.Equals(“B”)

Check below for workflow and output file(final output is written in sheet1)

Main (1).xaml (19.1 KB)

output.xlsx (8.9 KB)


@Manjuts90 Thanks for you help. I have another quick question. I want to change every Key 1 doesn’t matter what the content of Key 2. I tried to do it with a wildcard (* and ?) but that doesn’t seem to work, do you have an idea?
row(“Key 1”).ToString.Equals(“S”) And row(“Key 2”).ToString.Equals(“*”).


If key2 column value doesn’t matter then use below condition is enough.

row(“Key 1”).ToString.Trim.Equals(“S”)

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