Paste array values in diffrent rows of same column


Hi Guys,
I have a string array and i want to input these array values into a datatable but under a specific column say ‘E’.

Any help is greatly appreciated!



There are a few approaches.

If you wanted to add this array to an entire row, then it’s easy; just use Add Data Row and put the array in the Array property.

However, you want to put the array into a column, so you need to either A) use a For each, or B) manipulate the array to a CSV-comma delimitted file.


Read Range
For each row In datatable
    Assign row(4) = arrayVar( datatable.Rows.IndexOf(row) )

// or if you want a new table
Build Data Table
For each item in arrayvar // typeargument string
    Add Data Row
    Assign datatable.Rows( Array.IndexOf( arrayvar, item) ).Item(4) = item

EDIT: for correction


Assign strTable = String.Join( System.Environment.Newline, (From item In arrayvar Select ",,,,"+item ).ToArray )
Write Text File // to file.CSV

Hope you find this helpful.



Thanks i tried this… now the issue i am facing is the length of array is quite small (25) than the length of actual rows(200). after array elements run out … i get an error


Try using .Take() so it only does the amount of rows as you have array values.
You’ll need to change the “For each row” to a generic “For each” and set the TypeArgument to DataRow

For each row In datatable.AsEnumerable.Take( arrayVar.Count ).CopyToDataTable



I want to try this out but AsEnumerable is not an option for datatable.


Got this working by using the break activity in for each row as soon as counter >= length of array.

Thanks or your help @ClaytonM