Replace one row name(thaar) with row name(Audi) in excel in uipath

replace one row name(thaar) with row name(Audi) in excel in UiPath

Hi @Shravan_Pintu
Use Read Range activity and stored in variable dt.
Use the For Each Row activity to iterate through each row in the DataTable.
Inside the loop, add an If activity to check if the row contains thaar in the specific column.
row(0).ToString.Equals(“thaar”)
use an Assign activity Then part to replace the value in that cell with Audi.
row(0)=“Audi”

I hope this will work

Thanks

You can attempt this in multiple ways

1 you can read this excel store result in data table
2. Use for each row active to iterate through data table
3. Now assume your for each row variable is current row
4. In the inside block add if condition like
5. Currentrow(cars).item.tostring.tolower.trim.euqals(“thaar”)
6. Then in if condition is true add the assign activity where on the left side pass currentrow(“cars”) = “audi”

You can achieve this by using linq also

Hope this was helpful :blush: @Shravan_Pintu

@Shravan_Pintu,

Use this LINQ in Invoke Code activity.

(From row In yourDataTable.AsEnumerable()
 Where row.Field(Of String)("cars") = "thaar"
 Select row).ToList().ForEach(Sub(row) row.SetField("cars", "Audi"))

@Shravan_Pintu

Use find/replace activity and you can replace all or the cirst occurance with required value

Cheers

1 Like

How to use “value to find” and “replace with”

need to replace one banana name with mango

@Shravan_Pintu,

Configure it like this

Value to find = “Banana”
Replace with = “Mango”

its replacing all banana fields with mango

i want to replace only one banana with mango

@Shravan_Pintu,

Any specific n th value like first/last or 2nd like this?

any banana field is fine,

output should be

2 bananas
1 mango

@Shravan_Pintu

you have given row count so youa re searching for 3

just give “Banana” and “Mango” in valut to find and replace with fields respectively

cheers

1 Like

@Shravan_Pintu,

Use this logic.

LINQ to print the counts

String.Join(", ", (From row In dtInput.AsEnumerable
                   From col In dtInput.Columns.Cast(Of DataColumn)
                   Group row(col.ColumnName).ToString.Trim.ToLower By fruit = row(col.ColumnName).ToString.Trim.ToLower Into Group
                   Select $"{fruit} {Group.Count}").ToArray)

Code:
TestProject (2).zip (60.0 KB)

Output:

1 Like

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