How to Write a String in a datatable under a specific column

Hello Every One i have the following problem:

I have a String: tmp_MyString = “2298,1936,2316,2092,1948,2247,2255,2736,2735,2908,2904,2885”

Now i have to add this string to another datatable under a specific Column “Kamapgnennummer” in each row like following

How can i do this ??

Thanks in advance

Convert the string to a list. For Each loop through the list and Add Row each value to a datatable. Then use Write Range to write the datatable to the H2 range.

@postwick Thanks for quick Response, But the H2 Range is not fixed , it will keep changing

I mean the Column “Kampagnennummer” might be shifted to some other range like I J K L etc as well

That’s why it’s a range. You can just designate the starting cell and it will write as many rows as it needs.

Then you need to account for that and provide the correct range to the Write Range activity.


Hope the below steps would help you resolve this

Initially use a excel application scope and pass the file path as input and inside that scope use the below activities

  1. Use a assign activity like this

arrvalue = Split(tmp_MyString,”,”)

Where arrvalue is a variable of type Array of string

  1. Now use a excel application scope and pass the file path as input and read the data with read datatable activity and get the output as dt

  2. Now use a assign activity like this

Str_position = Convert.ToChar(dt.Columns.IndexOf(“Kamapgnennummer”)+65).ToString

Where str_position is a string variable

  1. Again a assign activity like this

Counter = 0

Where counter is a int32 variable

  1. Now use a WHILE LOOP like this with a condition

Counter < arrvalue.Count

  1. Inside the loop use a WRITE CELL ACTIVITY
    Where mention the cell range like this

Str_position + (counter+2).ToString

And in input value mention as arrvalue(counter)

  1. Next to this write cell activity inside the while loop use a assign activity like this to increment the counter value

counter = counter + 2

That’s it
Cheers @Tarif_Mohammad