I have Datatable with several columns, for keeping this example simple I am keeping two columns (ID,CostCentre) both of which are stored in a datatable
Cost Centre Values Sample: 901200,832100,459212,…
I have 750 such rows.
I want to assign a unique number value in the ‘ID’ column w.r.t each CostCentre.
As 750 rows already exist, I want the ID’s to start with 751 and can be in the range 750-999.
After you have read the excel, you can retrieve the last value of the ‘id’ column.
Let’s say for this case it got ‘750’ as the value. You can then store this value in a variable and then use it in a loop to increment it, which you can update in the excel.
The process may look something like this:
assign idValue=
(From row In dt
Let a= row("id").ToString
Select a).Last
So this will give you the last value of the ‘id’ column.
Then you can use for each loop to increment the id and add to the excel