How to Update specific cell in a column dynamically

How can we update specific cell value based on other two fields

Username |LastName| Oct |Nov | Dec
Anita | Jha | 20.05 |30.6| 90.8

So how do we update if name =“Anita” and Month=“dec” it should update the amt in Dec column(cell) as 90.8

Hi @anmita

Perform following steps

  1. Use excel scope to open the files
  2. Use for each row in excel to loop through rows
  3. Inside for each use a if condition to check the conditions Eg:

Currentrow("Username").ToString.Contains("Anita")

  1. In then use a assign activity to set the data
    currentrow("Dec") = "90.8" or 90.8

If data is in datatable do the same with for each row in datatable and no excel is needed

cheers

Hello @Anil_G
Thanks for reference

Is there any other approach to update based on index values of row and column?

@anmita

So

  1. Use the same for loop

But assign would be

Assuming month is stored in a variable(Month)

CurrentRow(Month) = 90.8

2.Read the excel data into datatable(dt)
then
Assign(Row index is String type)
RowIndex = dt.Rows.IndexOf(dt.AsEnumerable.Where(function(x) x("Name").ToString.Trim.Equals("Anita"))).ToString
Assign(ColumnValue is String Type)
ColumnValue = chr(65 + dt.Columns.IndexOf(Month))

Use write cell

With cell value = ColumnValue + RowIndex
Cell data = 90.8 or “90.8”

For row index you can also use

Rowindex = dt.Rows.IndexOf(dt.Select("[Name]='Anita'")(0)).ToString

Hope this helps

cheers

cheers

Hello @anmita :wave: you can directly update like below mentioned type or else you can also use linq
dt.Select(“[Username ]=‘Anita’”)(0)(4)=90.8 or"90.8

1 Like