Copying Substring of a column to another column?

I have a datatable column where I would need a specific data(substring) from it. The specific data would then be placed in another datatable column.

How can I create a datatable column(ID) like this? Without using loops or formulas in excel where I would be placing the datatable?

Please advise.


1 Like

hii @Michael_de_Borja

try this,
Read Range Excel sheet —> dt (Datatable)
assign activity,


  1. dt: —> your whole datatable with column (Account, ID)
  2. New_dt: —> new datatable with column ID only.
1 Like

Thanks for your reply!
But what I need is both the columns.
I need the substring of Account column to be in ID column, as shown in the image.


1 Like


Use Read Range for the existing excel.

Add DataColumn with Column Name as ID

then use the below query

DataTableVariable2 = (From x In DataTableVariable1.AsEnumerable()
Select DataTableVariable1.Clone.Rows.Add({x(“Account”),convert.ToString(x(“Account”)).split("-"c)(1).Substring(0,3)})).copytodatatable

you can use DataTableVariable2 as u require


Thank you!

1 Like

Quick question! How do I attach the newly created column, directly to the same datatable?
Without the use of loops? :smiley: