I have excel file…There are columns User Field 1, User field 2, User field 3 etc.
User Field 1…User Field 2…User Field 3
D45445… 4545454…454545
5445454…w545454…D4544
D44545…e4545454…D54544
D44544…D454545454…D45454
D4454…e4545454…e54545
please use this for your reference consider this as my excel file User Field as cols
if the value starts with D in Any of above columns appears once in a row then Ignore…
If there is value starts with D, if appear in User Field 1 as well as User Field 2/3 then I need to create one new Row below my current row and Paste the Duplicate D value In that new Row…
If the value starts with D appears in both 3 User field 1/2/3 then I need to create two new rows and paste the value in other two rows
How to do that?? Please help me out!! Thanks in advance!!
You have to write macro in VBA inside the excel. Next you have to execute this macro in UiPath.
Maybe there is another option in UiPath but I do not know.
Read the excel file with a Read range activity, that can be used inside of an Excel application scope. The output will be a datatable. (Make sure that add headers option checked when using Read range. I recommend you to use column names without whitespaces. example: UserField1) Then you can use a For each activity for that datatable and add if decisions for the logic you wrote.
For example: For each Row in DataTable,
If (Row.Item(“User Field 1”).ToString.Startswith(“D”) and Row.Item(“User Field 2”).ToString.Startswith(“D”) and Row.Item(“User Field 3”).ToString.Startswith(“D”),…)
Hopefully you’ll be able to build the logic. For copying rows, in this for each logic, you can use Add data row activity and fill Array property to Row.ItemArray and add the row for the existing datatable. If you want to see it in your excel, you can add these new rows for a new datatable and then add this new datatable for the existing excel file using an Append Range activity inside an excel scope.