viewed from the “Person ID” column. because if the value in “person ID” is an even number then the result of the last position is definitely outside (in the last location column it is filled with “OUTSIDE”). but if the number of Person IDs is odd (1,3,5) then the last one must still be in the room. therefore it is filled with “Outside” only a few lines before the last one as shown in the picture sir
based on the odd or even number of person IDs. if the number is odd, then only a few lines before the last as shown in the image. if the number is even, then all of them are written “OUTSIDE”
=> Use the Use excel file activity and give the path of the excel.
=> Use for each excel row inside the Use excel file activity to iterate the each row in the excel.
=> Inside for each use If condition to check the Person ID is even or add. Then give the below condition.
CInt(CurrentRow(“Person ID”)) mod 2 = 0
In then block give the write cell activity to write the Outside in Last location column.
In else block give the another write cell activity to write the Inside in the Last Location Column.
Note - In Write cell activity give like this Currentrow.ByField(“Last Location”) and check the Auto increment row option.
As an alternate you can work on a datatable base and then write it back to excel. The main building concept is about grouping the data on the name column
read range - dtData
Assign Actvitiy
OutSideRows | List(Of DataRow) =
(From d in dtData.AsEnumerable()
Group d by d("Name").toString.Trim into grp=Group
Let isEven= CInt(grp.Last()("Person ID").toString.Trim) Mod 2 = 0
Select grp2 = If(isEven, grp.toList, grp.SkipLast(0).toList)).SelectMany(Function (x) x).ToList
For each activity | item in OutSideRows | TypeArgument: DataRow
Then better to use the LinQ query check the below one.
(From d In dtData.AsEnumerable() Let personID = CInt(d("Person ID").ToString().Trim()) Let isEven = personID Mod 2 = 0 Let resultValue = If(isEven, "OUTSIDE", "INSIDE") Select d.Field(Of String)("Last Location") = resultValue).CopytoDatatable()