This is my excel, i know columnC value, using that i need to add value to column G
How can i do that
For Each row In YourDataTableVariable
If row(“ColumnC”).ToString() = “KnownValue” Then
row(“ColumnG”) = “NewValueToAdd”
- Read Data:
- Use the “Read Range” activity to read data from Excel/CSV into a DataTable.
- Loop Through Rows:
- Use a “For Each Row” activity to go through each row in the DataTable.
- Check ColumnC Value:
- Inside the loop, use an “If” activity to check if the value in ColumnC matches your specified value.
plaintextCopy code
Condition: row("ColumnC").ToString = "YourSpecifiedValue"
- Update ColumnG:
- Inside the “Then” branch of the “If” activity, use an “Assign” activity to add a value to ColumnG.
plaintextCopy code
Assign: row("ColumnG") = "YourNewValue"
- Write Data:
- After the loop, use the “Write Range” activity to save the modified DataTable back to Excel/CSV.
if you want to find the index of the row having the column value
use the below expression
dt.AsEnumerable().tolist.FindIndex(Function(a) a("ColumnName").tostring.trim.equals("Your Value"))
As it is excel, Simplest would be to use find/replace activity which would give you the cell number in which you foudn the value you want to search in C
Then use write cell with range as Excel.Sheet("SheetName").Cell("G" + findreturnvalue.Replace("C",""))
If using classic then cell value would be only "G" + findreturnvalue.Replace("C","")
Hope this helps
Cheers